Revision 017160ed

b/Makefile.am
1024 1024
	test/data/htools/common-suffix.data \
1025 1025
	test/data/htools/empty-cluster.data \
1026 1026
	test/data/htools/hail-alloc-drbd.json \
1027
	test/data/htools/hail-alloc-invalid-network.json \
1027 1028
	test/data/htools/hail-alloc-invalid-twodisks.json \
1029
	test/data/htools/hail-alloc-restricted-network.json \
1028 1030
	test/data/htools/hail-alloc-twodisks.json \
1029 1031
	test/data/htools/hail-change-group.json \
1030 1032
	test/data/htools/hail-invalid-reloc.json \
b/src/Ganeti/HTools/Cluster.hs
847 847
                   (gr, genAllocNodes mggl nl cnt False >>=
848 848
                        tryAlloc nl il inst))
849 849
             groups''::[(Group.Group, Result AllocSolution)]
850
      all_msgs = filter_group_msgs ++ (concatMap solutionDescription sols)
850
      all_msgs = filter_group_msgs ++ concatMap solutionDescription sols
851 851
      goodSols = filterMGResults sols
852 852
      sortedSols = sortMGResults goodSols
853 853
  in case sortedSols of
b/test/data/htools/hail-alloc-invalid-network.json
1
{
2
  "cluster_tags": [],
3
  "instances": {},
4
  "ipolicy": {
5
    "max": {
6
      "disk-size": 2048
7
    },
8
    "min": {
9
      "disk-size": 1024
10
    }
11
  },
12
  "nodegroups": {
13
    "uuid-group-1": {
14
      "alloc_policy": "preferred",
15
      "ipolicy": {
16
        "disk-templates": [
17
          "drbd"
18
        ],
19
        "minmax": [
20
          {
21
            "max": {
22
              "cpu-count": 2,
23
              "disk-count": 8,
24
              "disk-size": 2048,
25
              "memory-size": 12800,
26
              "nic-count": 8,
27
              "spindle-use": 8
28
            },
29
            "min": {
30
              "cpu-count": 1,
31
              "disk-count": 1,
32
              "disk-size": 1024,
33
              "memory-size": 128,
34
              "nic-count": 1,
35
              "spindle-use": 1
36
            }
37
          }
38
        ],
39
        "spindle-ratio": 32.0,
40
        "std": {
41
          "cpu-count": 1,
42
          "disk-count": 1,
43
          "disk-size": 1024,
44
          "memory-size": 128,
45
          "nic-count": 1,
46
          "spindle-use": 1
47
        },
48
        "vcpu-ratio": 4.0
49
      },
50
      "name": "Group 1",
51
      "networks": ["uuid-net-1-1", "uuid-net-1-2"],
52
      "tags": []
53
    },
54
    "uuid-group-2": {
55
      "alloc_policy": "preferred",
56
      "ipolicy": {
57
          "disk-templates": [
58
              "file"
59
          ],
60
          "minmax": [
61
              {
62
                  "max": {
63
                      "cpu-count": 2,
64
                      "disk-count": 8,
65
                      "disk-size": 2048,
66
                      "memory-size": 12800,
67
                      "nic-count": 8,
68
                      "spindle-use": 8
69
                  },
70
                  "min": {
71
                      "cpu-count": 1,
72
                      "disk-count": 1,
73
                      "disk-size": 1024,
74
                      "memory-size": 128,
75
                      "nic-count": 1,
76
                      "spindle-use": 1
77
                  }
78
              }
79
          ],
80
          "spindle-ratio": 32.0,
81
          "std": {
82
              "cpu-count": 1,
83
              "disk-count": 1,
84
              "disk-size": 1024,
85
              "memory-size": 128,
86
              "nic-count": 1,
87
              "spindle-use": 1
88
          },
89
          "vcpu-ratio": 4.0
90
      },
91
      "name": "Group 2",
92
      "networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"],
93
      "tags": []
94
    }
95
  },
96
  "nodes": {
97
    "node1_1": {
98
      "drained": false,
99
      "free_disk": 7168,
100
      "free_memory": 4096,
101
      "group": "uuid-group-1",
102
      "ndparams": {
103
        "spindle_count": 1
104
      },
105
      "offline": false,
106
      "reserved_memory": 1017,
107
      "total_cpus": 4,
108
      "total_disk": 7168,
109
      "total_memory": 4096
110
    },
111
    "node2_1": {
112
      "drained": false,
113
      "free_disk": 7168,
114
      "free_memory": 4096,
115
      "group": "uuid-group-2",
116
      "ndparams": {
117
        "spindle_count": 1
118
      },
119
      "offline": false,
120
      "reserved_memory": 1017,
121
      "total_cpus": 4,
122
      "total_disk": 7168,
123
      "total_memory": 4096
124
    }
125
  },
126
  "request": {
127
    "disk_space_total": 1536,
128
    "disk_template": "file",
129
    "disks": [
130
      {
131
        "size": 1536
132
      }
133
    ],
134
    "memory": 1024,
135
    "name": "instance1",
136
    "required_nodes": 1,
137
    "spindle_use": 2,
138
    "nics":[
139
      {
140
        "mac":"aa:00:00:85:f3:a7",
141
        "network":"uuid-net-1-1",
142
        "nicparams":{}
143
      },
144
      {
145
        "mac":"aa:00:00:85:f3:a8",
146
        "network":"uuid-net-1-2",
147
        "nicparams":{}
148
      }
149
    ],
150
    "tags": [],
151
    "type": "allocate",
152
    "vcpus": 1
153
  },
154
  "version": 2
155
}
b/test/data/htools/hail-alloc-restricted-network.json
1
{
2
  "cluster_tags": [],
3
  "instances": {
4
    "instance1": {
5
      "disks": [
6
        {
7
          "mode": "rw",
8
          "size": 1024
9
        }
10
      ],
11
      "disk_space_total": 1024,
12
      "hypervisor": "xen-pvm",
13
      "tags": [],
14
      "nics": [
15
        {
16
          "ip": null,
17
          "mac": "aa:00:00:eb:0b:a5",
18
          "link": "xen-br0",
19
          "mode": "bridged",
20
          "bridge": "xen-br0"
21
        }
22
      ],
23
      "vcpus": 1,
24
      "spindle_use": 1,
25
      "admin_state": "down",
26
      "disk_template": "drbd",
27
      "memory": 128,
28
      "nodes": [
29
        "node1_1",
30
        "node1_2"
31
      ],
32
      "os": "debian-image"
33
    },
34
    "instance2": {
35
      "disks": [
36
        {
37
          "mode": "rw",
38
          "size": 1024
39
        }
40
      ],
41
      "disk_space_total": 1024,
42
      "hypervisor": "xen-pvm",
43
      "tags": [],
44
      "nics": [
45
        {
46
          "ip": null,
47
          "mac": "aa:00:00:eb:0b:a5",
48
          "link": "xen-br0",
49
          "mode": "bridged",
50
          "bridge": "xen-br0"
51
        }
52
      ],
53
      "vcpus": 1,
54
      "spindle_use": 1,
55
      "admin_state": "down",
56
      "disk_template": "drbd",
57
      "memory": 128,
58
      "nodes": [
59
        "node1_2",
60
        "node1_1"
61
      ],
62
      "os": "debian-image"
63
    },
64
    "instance2": {
65
      "disks": [
66
        {
67
          "mode": "rw",
68
          "size": 1024
69
        }
70
      ],
71
      "disk_space_total": 1024,
72
      "hypervisor": "xen-pvm",
73
      "tags": [],
74
      "nics": [
75
        {
76
          "ip": null,
77
          "mac": "aa:00:00:eb:0b:a5",
78
          "link": "xen-br0",
79
          "mode": "bridged",
80
          "bridge": "xen-br0"
81
        }
82
      ],
83
      "vcpus": 1,
84
      "spindle_use": 1,
85
      "admin_state": "down",
86
      "disk_template": "drbd",
87
      "memory": 128,
88
      "nodes": [
89
        "node1_1",
90
        "node1_2"
91
      ],
92
      "os": "debian-image"
93
    }
94
  },
95
  "ipolicy": {
96
    "max": {
97
      "disk-size": 2048
98
    },
99
    "min": {
100
      "disk-size": 1024
101
    }
102
  },
103
  "nodegroups": {
104
    "uuid-group-1": {
105
      "alloc_policy": "last_resort",
106
      "ipolicy": {
107
        "disk-templates": [
108
          "drbd"
109
        ],
110
        "minmax": [
111
          {
112
            "max": {
113
              "cpu-count": 2,
114
              "disk-count": 8,
115
              "disk-size": 2048,
116
              "memory-size": 12800,
117
              "nic-count": 8,
118
              "spindle-use": 8
119
            },
120
            "min": {
121
              "cpu-count": 1,
122
              "disk-count": 1,
123
              "disk-size": 1024,
124
              "memory-size": 128,
125
              "nic-count": 1,
126
              "spindle-use": 1
127
            }
128
          }
129
        ],
130
        "spindle-ratio": 32.0,
131
        "std": {
132
          "cpu-count": 1,
133
          "disk-count": 1,
134
          "disk-size": 1024,
135
          "memory-size": 128,
136
          "nic-count": 1,
137
          "spindle-use": 1
138
        },
139
        "vcpu-ratio": 4.0
140
      },
141
      "name": "Group 1",
142
      "networks": ["uuid-net-1-1", "uuid-net-1-2"],
143
      "tags": []
144
    },
145
    "uuid-group-2": {
146
      "alloc_policy": "preferred",
147
      "ipolicy": {
148
          "disk-templates": [
149
              "drbd"
150
          ],
151
          "minmax": [
152
              {
153
                  "max": {
154
                      "cpu-count": 2,
155
                      "disk-count": 8,
156
                      "disk-size": 2048,
157
                      "memory-size": 12800,
158
                      "nic-count": 8,
159
                      "spindle-use": 8
160
                  },
161
                  "min": {
162
                      "cpu-count": 1,
163
                      "disk-count": 1,
164
                      "disk-size": 1024,
165
                      "memory-size": 128,
166
                      "nic-count": 1,
167
                      "spindle-use": 1
168
                  }
169
              }
170
          ],
171
          "spindle-ratio": 32.0,
172
          "std": {
173
              "cpu-count": 1,
174
              "disk-count": 1,
175
              "disk-size": 1024,
176
              "memory-size": 128,
177
              "nic-count": 1,
178
              "spindle-use": 1
179
          },
180
          "vcpu-ratio": 4.0
181
      },
182
      "name": "Group 2",
183
      "networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"],
184
      "tags": []
185
    }
186
  },
187
  "nodes": {
188
    "node1_1": {
189
      "drained": false,
190
      "free_disk": 4096,
191
      "free_memory": 3840,
192
      "group": "uuid-group-1",
193
      "ndparams": {
194
        "spindle_count": 1
195
      },
196
      "offline": false,
197
      "reserved_memory": 1017,
198
      "total_cpus": 4,
199
      "total_disk": 7168,
200
      "total_memory": 4096
201
    },
202
    "node1_2": {
203
      "drained": false,
204
      "free_disk": 4096,
205
      "free_memory": 3968,
206
      "group": "uuid-group-1",
207
      "ndparams": {
208
        "spindle_count": 1
209
      },
210
      "offline": false,
211
      "reserved_memory": 1017,
212
      "total_cpus": 4,
213
      "total_disk": 7168,
214
      "total_memory": 32763
215
    },
216
    "node2_1": {
217
      "drained": false,
218
      "free_disk": 7168,
219
      "free_memory": 4096,
220
      "group": "uuid-group-2",
221
      "ndparams": {
222
        "spindle_count": 1
223
      },
224
      "offline": false,
225
      "reserved_memory": 1017,
226
      "total_cpus": 4,
227
      "total_disk": 7168,
228
      "total_memory": 4096
229
    },
230
    "node2_2": {
231
      "drained": false,
232
      "free_disk": 7168,
233
      "free_memory": 4096,
234
      "group": "uuid-group-2",
235
      "ndparams": {
236
        "spindle_count": 1
237
      },
238
      "offline": false,
239
      "reserved_memory": 1017,
240
      "total_cpus": 4,
241
      "total_disk": 7168,
242
      "total_memory": 4096
243
    }
244
  },
245
  "request": {
246
    "disk_space_total": 3072,
247
    "disk_template": "drbd",
248
    "disks": [
249
      {
250
        "size": 1536
251
      },
252
      {
253
        "size": 1536
254
      }
255
    ],
256
    "memory": 1024,
257
    "name": "instance1",
258
    "required_nodes": 2,
259
    "spindle_use": 2,
260
    "nics":[
261
      {
262
        "mac":"aa:00:00:85:f3:a7",
263
        "network":"uuid-net-1-1",
264
        "nicparams":{}
265
      },
266
      {
267
        "mac":"aa:00:00:85:f3:a8",
268
        "network":"uuid-net-1-2",
269
        "nicparams":{}
270
      }
271
    ],
272
    "tags": [],
273
    "type": "allocate",
274
    "vcpus": 1
275
  },
276
  "version": 2
277
}
b/test/hs/shelltests/htools-hail.test
47 47
>>> /"success":false,.*FailDisk: 1/
48 48
>>>= 0
49 49

  
50
# check that hail honors network requirements
51
./test/hs/hail $TESTDATA_DIR/hail-alloc-restricted-network.json
52
>>> /"success":true,"info":"Request successful: Selected group: Group 1.*/
53
>>>= 0
54

  
55
# check that hail fails if no nodegroup can meet network and disk template requirements
56
./test/hs/hail $TESTDATA_DIR/hail-alloc-invalid-network.json
57
>>> /"success":false,/
58
>>>= 0
59

  
60
# check that hail succeeds with the same test data, but with the network restrictions removed
61
cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid-net-1-."' | ./test/hs/hail -
62
>>> /"success":true,"info":"Request successful: Selected group: Group 2.*/
63
>>>= 0
64

  
50 65
# check that hail can use the simu backend
51 66
./test/hs/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
52 67
>>> /"success":true,/

Also available in: Unified diff