in the form::
{"instance-name":{
- "disk_size": 25,
- "swap_size": 1024,
+ "disk_size": [20480],
"template": "drbd",
"backend": {
"memory": 512,
"vcpus": 1 },
- "os": "etch-image",
+ "os": "debootstrap",
"primary_node": "firstnode",
"secondary_node": "secondnode",
"iallocator": "dumb"}
@return: the desired exit code
"""
- _DEFAULT_SPECS = {"disk_size": 20 * 1024,
- "swap_size": 4 * 1024,
+ _DEFAULT_SPECS = {"disk_size": [20 * 1024],
"backend": {},
"iallocator": None,
"primary_node": None,
# Iterate over the instances and do:
# * Populate the specs with default value
# * Validate the instance specs
- for (name, specs) in instance_data.iteritems():
+ i_names = utils.NiceSort(instance_data.keys())
+ for name in i_names:
+ specs = instance_data[name]
specs = _PopulateWithDefaults(specs)
_Validate(specs)
if specs['hypervisor']:
hypervisor, hvparams = specs['hypervisor'].iteritems()
+ disks = []
+ for elem in specs['disk_size']:
+ try:
+ size = utils.ParseUnit(elem)
+ except ValueError, err:
+ raise errors.OpPrereqError("Invalid disk size '%s' for"
+ " instance %s: %s" %
+ (elem, name, err))
+ disks.append({"size": size})
+
+ nic0 = {'ip': specs['ip'], 'bridge': specs['bridge'], 'mac': specs['mac']}
+
op = opcodes.OpCreateInstance(instance_name=name,
- disk_size=specs['disk_size'],
- swap_size=specs['swap_size'],
+ disks=disks,
disk_template=specs['template'],
mode=constants.INSTANCE_CREATE,
os_type=specs['os'],
pnode=specs['primary_node'],
snode=specs['secondary_node'],
- ip=specs['ip'], bridge=specs['bridge'],
+ nics=[nic0],
start=specs['start'],
ip_check=specs['ip_check'],
wait_for_sync=True,
- mac=specs['mac'],
iallocator=specs['iallocator'],
hypervisor=hypervisor,
hvparams=hvparams,
The migrate is done without shutdown.
- Args:
- opts - class with options as members
- args - list with a single element, the instance name
- Opts used:
- force - whether to migrate without asking questions.
+ @param opts: the command line options selected by the user
+ @type args: list
+ @param args: should contain only one element, the instance name
+ @rtype: int
+ @return: the desired exit code
"""
instance_name = args[0]
metavar="<DIR>"),
make_option("--file-driver", dest="file_driver", help="Driver to use"
" for image files", default="loop", metavar="<DRIVER>"),
- make_option("--iallocator", metavar="<NAME>",
+ make_option("-I", "--iallocator", metavar="<NAME>",
help="Select nodes for the instance automatically using the"
" <NAME> iallocator plugin", default=None, type="string"),
ikv_option("-H", "--hypervisor", dest="hypervisor",