blob: 65fedb117c05463e8cd592e0985c8d181d3a82f9 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/*
common-models.js
Defines classes used by the workflows
Functions as the "model" part of MVC
*/
// Provided by the LibLaaS API
// TemplateBlob classes
class TemplateBlob {
constructor(incomingBlob) {
this.id = incomingBlob.id; // UUID (String)
this.owner = incomingBlob.owner; // String
this.lab_name = incomingBlob.lab_name; // String
this.pod_name = incomingBlob.pod_name; // String
this.pod_desc = incomingBlob.pod_desc; // String
this["public"] = incomingBlob["public"]; // bool
this.host_list = []; // List<HostConfigBlob>
this.networks = []; // List<NetworkBlob>
if (incomingBlob.host_list) {
this.host_list = incomingBlob.host_list;
}
if (incomingBlob.networks) {
this.networks = incomingBlob.networks;
}
}
/**
* Takes a network name (string) and returns the network stored in the template, or null if it does not exist
* @param {String} network_name
*/
findNetwork(network_name) {
for (const network of this.networks) {
if (network.name == network_name) {
return network;
}
}
// Did not find it
return null;
}
/**
* Takes a hostname (string) and returns the host stored in the template, or null if it does not exist
* @param {String} hostname
*/
findHost(hostname) {
for (const host of this.host_list) {
if (host.hostname == hostname) {
return host;
}
}
// Did not find it
return null;
}
}
class HostConfigBlob {
constructor(incomingBlob) {
this.hostname = incomingBlob.hostname; // String
this.flavor = incomingBlob.flavor; // UUID (String)
this.image = incomingBlob.image; // UUID (String)
this.cifile = []; // List<String>
this.bondgroups = []; // List<BondgroupBlob>
if (incomingBlob.cifile) {
this.cifile = incomingBlob.cifile;
}
if (incomingBlob.bondgroups) {
this.bondgroups = incomingBlob.bondgroups;
}
}
}
class NetworkBlob {
constructor(incomingBlob) {
this.name = incomingBlob.name;
this['public'] = incomingBlob['public'];
}
}
/** One bondgroup per interface at this time. */
class BondgroupBlob {
constructor(incomingBlob) {
this.connections = []; //List<ConnectionBlob>
this.ifaces = []; // List<IfaceBlob> (will only contain the one iface for now)
if (incomingBlob.connections) {
this.connections = incomingBlob.connections;
}
if (incomingBlob.ifaces) {
this.ifaces = incomingBlob.ifaces;
}
}
}
class ConnectionBlob {
constructor(incomingBlob) {
this.tagged = incomingBlob.tagged; // bool,
this.connects_to = incomingBlob.connects_to; // String
}
}
class InterfaceBlob {
constructor(incomingBlob) {
this.name = incomingBlob.name; // String,
this.speed = incomingBlob.speed;
this.cardtype = incomingBlob.cardtype;
}
}
// BookingClasses
class BookingBlob {
// constructor({template_id, allowed_users, global_cifile}) {
constructor(incomingBlob) {
this.template_id = incomingBlob.template_id; // UUID (String)
this.allowed_users = []; // List<String>
this.global_cifile = ""; // String
this.metadata = new BookingMetaDataBlob({});
if (incomingBlob.allowed_users) {
this.allowed_users = incomingBlob.allowed_users;
}
if (incomingBlob.global_cifile) {
this.global_cifile = incomingBlob.global_cifile;
}
if (incomingBlob.metadata) {
this.metadata = incomingBlob.metadata;
}
}
}
class BookingMetaDataBlob {
constructor(incomingBlob) {
this.booking_id = incomingBlob.booking_id; // String
this.owner = incomingBlob.owner; // String
this.lab = incomingBlob.lab; // String
this.purpose = incomingBlob.purpose; // String
this.project = incomingBlob.project; // String
this.length = 1 // Number
if (incomingBlob.length) {
this.length = incomingBlob.length;
}
}
}
// Utility Classes
class ImageBlob {
constructor(incomingBlob) {
this.image_id = incomingBlob.image_id; // UUID (String)
this.name = incomingBlob.name; // String,
}
}
class FlavorBlob {
constructor(incomingBlob) {
this.flavor_id = incomingBlob.flavor_id; // UUID (String)
this.name = incomingBlob.name; // String
this.interfaces = []; // List<String>
// images are added after
if (incomingBlob.interfaces) {
this.interfaces = incomingBlob.interfaces;
}
}
}
class LabBlob {
constructor(incomingBlob) {
this.name = incomingBlob.name; // String
this.description = incomingBlob.description; // String
this.location = incomingBlob.location; //String
this.status = incomingBlob.status; // Number
}
}
|