From 01f20372f2ad7ac818306e28a842a66c343a3ddf Mon Sep 17 00:00:00 2001 From: Mike Arpaia Date: Wed, 12 Oct 2016 15:19:27 -0400 Subject: [PATCH] Populate the in-memory database with fake hosts (#304) * Populate the in-memory database with fake hosts Similarly to how we create two fake users, this PR adds two fake hosts to the in-memory database that is used in dev mode. * using more realistic physical memory values --- cli/serve.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cli/serve.go b/cli/serve.go index 8d46a2d143..62b23410d8 100644 --- a/cli/serve.go +++ b/cli/serve.go @@ -7,6 +7,7 @@ import ( "os" "os/signal" "syscall" + "time" "github.com/WatchBeam/clock" kitlog "github.com/go-kit/kit/log" @@ -82,6 +83,7 @@ the way that the kolide server works. if devMode { createDevUsers(ds, config) + createDevHosts(ds, config) createDevOrgInfo(svc, config) } @@ -206,6 +208,44 @@ func createDevUsers(ds kolide.Datastore, config config.KolideConfig) { } } +// Bootstrap a few hosts when using the in-memory database. +func createDevHosts(ds kolide.Datastore, config config.KolideConfig) { + hosts := []kolide.Host{ + { + NodeKey: "totally-legit", + HostName: "jmeller-mbp.local", + UUID: "1234-5678-9101", + Platform: "darwin", + OsqueryVersion: "2.0.0", + OSVersion: "10.10.1", + Uptime: 60 * time.Minute, + PhysicalMemory: 4145483776, + PrimaryMAC: "10:11:12:13:14:15", + PrimaryIP: "192.168.1.10", + }, + { + NodeKey: "definitely-legit", + HostName: "marpaia.local", + UUID: "1234-5678-9102", + Platform: "windows", + OsqueryVersion: "2.0.0", + OSVersion: "1607", + Uptime: 60 * time.Minute, + PhysicalMemory: 17179869184, + PrimaryMAC: "10:11:12:13:14:16", + PrimaryIP: "192.168.1.11", + }, + } + + for _, host := range hosts { + host := host + _, err := ds.NewHost(&host) + if err != nil { + initFatal(err, "creating bootstrap host") + } + } +} + func createDevOrgInfo(svc kolide.Service, config config.KolideConfig) { devOrgInfo := &kolide.OrgInfo{ OrgName: "Kolide",