summaryrefslogtreecommitdiff
path: root/sampleData.go
blob: 32e89f078c7cfe89469590a6f15a1162bacf8126 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package virtbuf

import (
	"fmt"
	"log"

	"github.com/google/uuid"
	// anypb "google.golang.org/protobuf/types/known/anypb"
)

//
// This generates some sample data.
//

func CreateSampleDroplet(hostname string) *Droplet {
	// TODO: flush this out to do all the fields
	log.Println("CreateSampleDroplet() is generating a new droplet", hostname)

	// Generate a new UUID
	id := uuid.New()
	d := &Droplet{
		Uuid:     id.String(),
		Hostname: hostname,
	}
	return d
}

func CreateSampleHypervisor(hostname string, mem int) *Hypervisor {
	// Generate a new UUID
	id := uuid.New()
	h := &Hypervisor{
		Uuid:     id.String(),
		Hostname: hostname,
		Cpus:     16,
		Memory:   256,
		Comment:  "this is a fake hypervisor",
	}
	h.SetMemoryGB(mem * 32)
	return h
}

func CreateExperiment(total int) *WhatsThis {
	var e *WhatsThis
	e = new(WhatsThis)

	//	info := StorageInfo{Capacity: 64}
	//	e.Humantest = &info
	if e.Humantest == nil {
		var newInfo WhatInfo
		newInfo = WhatInfo{Capacity: 64}
		e.Humantest = &newInfo
	} else {
		e.Humantest.Capacity = SetGB(total * 32)
	}
	return e
}

func CreateSampleEvents(total int) *Events {
	var e *Events
	e = new(Events)

	for i := 0; i < total; i++ {
		var newe *Event
		newe = new(Event)
		e.Events = append(e.Events, newe)
	}
	return e
}

func CreateSampleCluster(total int) *Cluster {
	c := InitCluster()

	for i := 0; i < total; i++ {
		hostname := fmt.Sprintf("bmath%d.wit.com", i)
		d := CreateSampleDroplet(hostname)
		d.PreferredHypervisor = fmt.Sprintf("farm%d", i)
		if d.PreferredHypervisor == "farm4" {
			d.Cpus = 16
			d.Memory = SetGB(256)
		}

		c.d.Droplets = append(c.d.Droplets, d)
	}

	for i := 0; i < 3; i++ {
		hostname := fmt.Sprintf("farm%d", i)
		h := CreateSampleHypervisor(hostname, i+1)
		h.Comment = fmt.Sprintf("Sample hypervisor %d", i)

		c.H.Hypervisors = append(c.H.Hypervisors, h)
	}

	return c
}