74
74
num_disks = node.get('num_drives', 1)
77
raise exception.ApiError(_("No drive_name param found in %s"),
77
raise exception.ApiError(_("No drive_name param found in %s")
80
80
# find DB record for this disk
82
82
drive_ref = drive_types.get_by_name(context, name)
83
83
except exception.NotFound:
84
raise exception.ApiError(_("Invalid drive type name %s"),
84
raise exception.ApiError(_("Invalid drive type name %s")
87
87
# if size field present - override disk size specified in DB
88
88
size = node.get('size', drive_ref['size_gb'])
149
149
vc_image = image_service.show_by_name(context, image_name)
150
150
vc_image_href = vc_image['id']
151
151
except exception.ImageNotFound:
152
raise exception.ApiError(_("Failed to find configured image %s"),
152
raise exception.ApiError(_("Failed to find configured image %s")
156
156
'display_name': display_name,
259
259
LOG.info(_("VSA ID %(vsa_id)d: Update VSA call"), locals())
261
updatable_fields = ['status', 'vc_count', 'vol_count',
262
'display_name', 'display_description']
264
for field in updatable_fields:
266
changes[field] = kwargs[field]
261
268
vc_count = kwargs.get('vc_count', None)
262
269
if vc_count is not None:
263
270
# VP-TODO: This request may want to update number of VCs
264
271
# Get number of current VCs and add/delete VCs appropriately
265
272
vsa = self.get(context, vsa_id)
266
273
vc_count = int(vc_count)
274
if vc_count > FLAGS.max_vcs_in_vsa:
275
LOG.warning(_("Requested number of VCs (%d) is too high."\
276
" Setting to default"), vc_count)
277
vc_count = FLAGS.max_vcs_in_vsa
267
279
if vsa['vc_count'] != vc_count:
268
280
self.update_num_vcs(context, vsa, vc_count)
281
changes['vc_count'] = vc_count
270
return self.db.vsa_update(context, vsa_id, kwargs)
283
return self.db.vsa_update(context, vsa_id, changes)
272
285
def update_num_vcs(self, context, vsa, vc_count):
273
if vc_count > FLAGS.max_vcs_in_vsa:
274
LOG.warning(_("Requested number of VCs (%d) is too high."\
275
" Setting to default"), vc_count)
276
vc_count = FLAGS.max_vcs_in_vsa
278
286
vsa_name = vsa['name']
279
old_vc_count = vsa['vc_count']
287
old_vc_count = int(vsa['vc_count'])
280
288
if vc_count > old_vc_count:
281
289
add_cnt = vc_count - old_vc_count
282
LOG.debug(_("Adding %(add_cnt)d VCs to VSA %(vsa_name)s."),
290
LOG.debug(_("Adding %(add_cnt)s VCs to VSA %(vsa_name)s."),
284
292
# VP-TODO: actual code for adding new VCs
286
294
elif vc_count < old_vc_count:
287
295
del_cnt = old_vc_count - vc_count
288
LOG.debug(_("Deleting %(add_cnt)d VCs from VSA %(vsa_name)s."),
296
LOG.debug(_("Deleting %(del_cnt)s VCs from VSA %(vsa_name)s."),
290
298
# VP-TODO: actual code for deleting extra VCs
372
380
e_vsa_detail = SubElement(e_vsa, "vc_count")
373
381
e_vsa_detail.text = str(vsa['vc_count'])
374
382
e_vsa_detail = SubElement(e_vsa, "auth_user")
375
e_vsa_detail.text = str(context.user.name)
383
if context.user is not None:
384
e_vsa_detail.text = str(context.user.name)
376
385
e_vsa_detail = SubElement(e_vsa, "auth_access_key")
377
e_vsa_detail.text = str(context.user.access)
386
if context.user is not None:
387
e_vsa_detail.text = str(context.user.access)
379
389
e_volumes = SubElement(e_vsa, "volumes")
380
390
for volume in volumes: