Revision 2f7635f4

b/lib/rapi/rlib1.py
33 33
from ganeti.rapi import baserlib
34 34

  
35 35

  
36
I_FIELDS = ["name", "os", "pnode", "snodes",
37
            "admin_state", "admin_ram",
38
            "disk_template", "ip", "mac", "bridge",
39
            "sda_size", "sdb_size", "vcpus",
36
I_FIELDS = ["name", "os", "pnode", "snodes", "admin_state", "disk_template",
37
            "ip", "mac", "bridge", "sda_size", "sdb_size", "be/vcpus",
38
            "be/memory", "be/auto_balance",
40 39
            "oper_state", "status", "tags"]
41 40

  
42 41
N_FIELDS = ["name", "dtotal", "dfree",
......
276 275

  
277 276
    return baserlib.MapFields(I_FIELDS, result[0])
278 277

  
278
  def DELETE(self):
279
    """Removes an instance.
280

  
281
    """
282
    instance_name = self.items[0]
283
    op = ganeti.opcodes.OpRemoveInstance(instance_name=instance_name,
284
                                         ignore_failures=True)
285
    job_id = ganeti.cli.SendJob([op])
286

  
287
    return job_id
288

  
279 289

  
280 290
class R_instances_name_tags(baserlib.R_Generic):
281 291
  """/instances/[instance_name]/tags resource.
b/lib/rapi/rlib2.py
139 139
  """
140 140
  DOC_URI = "/2/instances"
141 141

  
142

  
143 142
  def GET(self):
144 143
    """Returns a list of all available instances.
145 144

  
......
197 196
      return baserlib.BuildUriList(instanceslist, "/2/instances/%s",
198 197
                                   uri_fields=("id", "uri"))
199 198

  
199
  def PUT(self):
200
    """Create an instance.
201

  
202
    Returns:
203
      A job id.
204

  
205
    """
206
    opts = self.post_data
207

  
208
    # beparams
209
    mem = opts.get('mem', None)
210
    vcpus = opts.get('vcpus', None)
211
    auto_balance = opts.get('auto_balance', None)
212

  
213
    beparams = {}
214

  
215
    for key, const in [(mem, constants.BE_MEMORY),
216
                       (vcpus, constants.BE_VCPUS),
217
                       (auto_balance, constants.BE_AUTO_BALANCE)]:
218
      if key is not None:
219
        beparams[const] = key
220

  
221
    op = ganeti.opcodes.OpCreateInstance(
222
        instance_name=opts.get('name'),
223
        disk_size=opts.get('size', 20 * 1024),
224
        swap_size=opts.get('swap', 4 * 1024),
225
        disk_template=opts.get('disk_template', None),
226
        mode=constants.INSTANCE_CREATE,
227
        os_type=opts.get('os'),
228
        pnode=opts.get('pnode'),
229
        snode=opts.get('snode'),
230
        ip=opts.get('ip', 'none'),
231
        bridge=opts.get('bridge', None),
232
        start=opts.get('start', True),
233
        ip_check=opts.get('ip_check', True),
234
        wait_for_sync=opts.get('wait_for_sync', True),
235
        mac=opts.get('mac', 'auto'),
236
        hypervisor=opts.get('hypervisor', None),
237
        hvparams=opts.get('hvparams', {}),
238
        beparams=beparams,
239
        iallocator=opts.get('iallocator', None),
240
        file_storage_dir=opts.get('file_storage_dir', None),
241
        file_driver=opts.get('file_driver', 'loop'),
242
        )
243

  
244
    job_id = ganeti.cli.SendJob([op])
245
    return job_id
246

  
200 247

  
201 248
class R_2_instances_name_tags(baserlib.R_Generic):
202 249
  """/2/instances/[instance_name]/tags resource.

Also available in: Unified diff