mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
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
This commit is contained in:
parent
93eaae7454
commit
01f20372f2
1 changed files with 40 additions and 0 deletions
40
cli/serve.go
40
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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue