Revision 76ba77c1 api/servers.py

b/api/servers.py
169 169
        ipfour='0.0.0.0',
170 170
        ipsix='::1',
171 171
        flavor=flavor)
172

  
173
    # Pick a random password for the VM.
174
    # FIXME: This must be passed to the Ganeti OS provider via CreateInstance()
175
    passwd = random_password()
176

  
177
    # We *must* save the VM instance now,
178
    # so that it gets a vm.id and vm.backend_id is valid.
179
    vm.save() 
172 180
                
173 181
    if request.META.get('SERVER_NAME', None) == 'testserver':
174
        name = 'test-server'
182
        backend_name = 'test-server'
175 183
        dry_run = True
176 184
    else:
177
        name = vm.backend_id
185
        backend_name = vm.backend_id
178 186
        dry_run = False
179
    
187

  
180 188
    jobId = rapi.CreateInstance(
181 189
        mode='create',
182
        name=name,
190
        name=backend_name,
183 191
        disk_template='plain',
184 192
        disks=[{"size": 2000}],         #FIXME: Always ask for a 2GB disk for now
185 193
        nics=[{}],
......
199 207
    
200 208
    server = vm_to_dict(vm, detail=True)
201 209
    server['status'] = 'BUILD'
202
    server['adminPass'] = random_password()
210
    server['adminPass'] = passwd
203 211
    return render_server(request, server, status=202)
204 212

  
205 213
@api_method('GET')

Also available in: Unified diff