Revision d61df03e scripts/gnt-debug
b/scripts/gnt-debug | ||
---|---|---|
97 | 97 |
return 0 |
98 | 98 |
|
99 | 99 |
|
100 |
def TestAllocator(opts, args): |
|
101 |
"""Runs the test allocator opcode""" |
|
102 |
|
|
103 |
try: |
|
104 |
disks = [{"size": utils.ParseUnit(val), "mode": 'w'} |
|
105 |
for val in opts.disks.split(",")] |
|
106 |
except errors.UnitParseError, err: |
|
107 |
print >> sys.stderr, "Invalid disks parameter '%s': %s" % (opts.disks, err) |
|
108 |
return 1 |
|
109 |
|
|
110 |
nics = [val.split("/") for val in opts.nics.split(",")] |
|
111 |
for row in nics: |
|
112 |
while len(row) < 3: |
|
113 |
row.append(None) |
|
114 |
for i in range(3): |
|
115 |
if row[i] == '': |
|
116 |
row[i] = None |
|
117 |
nic_dict = [{"mac": v[0], "ip": v[1], "bridge": v[2]} for v in nics] |
|
118 |
|
|
119 |
if opts.tags is None: |
|
120 |
opts.tags = [] |
|
121 |
else: |
|
122 |
opts.tags = opts.tags.split(",") |
|
123 |
|
|
124 |
op = opcodes.OpTestAllocator(mode=opts.mode, |
|
125 |
name=args[0], |
|
126 |
mem_size=opts.mem, |
|
127 |
disks=disks, |
|
128 |
disk_template=opts.disk_template, |
|
129 |
nics=nic_dict, |
|
130 |
os=opts.os_type, |
|
131 |
vcpus=opts.vcpus, |
|
132 |
tags=opts.tags, |
|
133 |
direction=opts.direction, |
|
134 |
allocator=opts.allocator, |
|
135 |
) |
|
136 |
result = SubmitOpCode(op) |
|
137 |
print result |
|
138 |
return 0 |
|
139 |
|
|
140 |
|
|
100 | 141 |
commands = { |
101 | 142 |
'delay': (Delay, ARGS_ONE, |
102 | 143 |
[DEBUG_OPT, |
... | ... | |
113 | 154 |
], |
114 | 155 |
"<op_list_file>", "Submits a job built from a json-file" |
115 | 156 |
" with a list of serialized opcodes"), |
157 |
'allocator': (TestAllocator, ARGS_ONE, |
|
158 |
[DEBUG_OPT, |
|
159 |
make_option("--dir", dest="direction", |
|
160 |
default="in", choices=["in", "out"], |
|
161 |
help="Show allocator input (in) or allocator" |
|
162 |
" results (out)"), |
|
163 |
make_option("--algorithm", dest="allocator", |
|
164 |
default=None, |
|
165 |
help="Allocator algorithm name"), |
|
166 |
make_option("-m", "--mode", default="relocate", |
|
167 |
choices=["relocate", "allocate"], |
|
168 |
help="Request mode, either allocate or" |
|
169 |
"relocate"), |
|
170 |
cli_option("--mem", default=128, type="unit", |
|
171 |
help="Memory size for the instance (MiB)"), |
|
172 |
make_option("--disks", default="4096,4096", |
|
173 |
help="Comma separated list of disk sizes (MiB)"), |
|
174 |
make_option("-t", "--disk-template", default="drbd", |
|
175 |
help="Select the disk template"), |
|
176 |
make_option("--nics", default="00:11:22:33:44:55", |
|
177 |
help="Comma separated list of nics, each nic" |
|
178 |
" definition is of form mac/ip/bridge, if" |
|
179 |
" missing values are replace by None"), |
|
180 |
make_option("-o", "--os-type", default=None, |
|
181 |
help="Select os for the instance"), |
|
182 |
make_option("-p", "--vcpus", default=1, type="int", |
|
183 |
help="Select number of VCPUs for the instance"), |
|
184 |
make_option("--tags", default=None, |
|
185 |
help="Comma separated list of tags"), |
|
186 |
], |
|
187 |
"{opts...} <instance>", "Executes a TestAllocator OpCode"), |
|
116 | 188 |
} |
117 | 189 |
|
118 | 190 |
|
Also available in: Unified diff