Revision 1c03e74e api/servers.py

b/api/servers.py
184 184
    else:
185 185
        backend_name = vm.backend_id
186 186
        dry_run = False
187

  
188
    jobId = rapi.CreateInstance(
189
        mode='create',
190
        name=backend_name,
191
        disk_template='plain',
192
        disks=[{"size": 2000}],         #FIXME: Always ask for a 2GB disk for now
193
        nics=[{}],
194
        os='debootstrap+default',       #TODO: select OS from imageRef
195
        ip_check=False,
196
        name_check=False,
197
        pnode=rapi.GetNodes()[0],       #TODO: verify if this is necessary
198
        dry_run=dry_run,
199
        beparams=dict(auto_balance=True, vcpus=flavor.cpu, memory=flavor.ram))
200
    
201
    vm.save()
202 187
    
188
    try:
189
        jobId = rapi.CreateInstance(
190
            mode='create',
191
            name=backend_name,
192
            disk_template='plain',
193
            disks=[{"size": 2000}],         #FIXME: Always ask for a 2GB disk for now
194
            nics=[{}],
195
            os='debootstrap+default',       #TODO: select OS from imageRef
196
            ip_check=False,
197
            name_check=False,
198
            pnode=rapi.GetNodes()[0],       #TODO: verify if this is necessary
199
            dry_run=dry_run,
200
            beparams=dict(auto_balance=True, vcpus=flavor.cpu, memory=flavor.ram))
201
    except Exception, e:
202
        vm.delete()
203
        raise e
204
        
203 205
    for key, val in metadata.items():
204 206
        VirtualMachineMetadata.objects.create(meta_key=key, meta_value=val, vm=vm)
205 207
    

Also available in: Unified diff