~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to nova/api/ec2/cloud.py

  • Committer: Tarmac
  • Author(s): Todd Willey
  • Date: 2010-09-29 04:13:25 UTC
  • mfrom: (278.1.9 rename)
  • Revision ID: hudson@openstack.org-20100929041325-9x2oqe7demmumosi
Add user-editable name & notes/description to volumes, instances, and images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
285
285
                                   'volume_id': volume['ec2_id']}]
286
286
        else:
287
287
            v['attachmentSet'] = [{}]
 
288
 
 
289
        v['display_name'] = volume['display_name']
 
290
        v['display_description'] = volume['display_description']
288
291
        return v
289
292
 
290
293
    def create_volume(self, context, size, **kwargs):
302
305
        vol['availability_zone'] = FLAGS.storage_availability_zone
303
306
        vol['status'] = "creating"
304
307
        vol['attach_status'] = "detached"
 
308
        vol['display_name'] = kwargs.get('display_name')
 
309
        vol['display_description'] = kwargs.get('display_description')
305
310
        volume_ref = db.volume_create(context, vol)
306
311
 
307
312
        rpc.cast(FLAGS.scheduler_topic,
368
373
            lst = [lst]
369
374
        return [{label: x} for x in lst]
370
375
 
 
376
    def update_volume(self, context, volume_id, **kwargs):
 
377
        updatable_fields = ['display_name', 'display_description']
 
378
        changes = {}
 
379
        for field in updatable_fields:
 
380
            if field in kwargs:
 
381
                changes[field] = kwargs[field]
 
382
        if changes:
 
383
            db.volume_update(context, volume_id, kwargs)
 
384
        return True
 
385
 
371
386
    def describe_instances(self, context, **kwargs):
372
387
        return self._format_describe_instances(context)
373
388
 
420
435
            i['instanceType'] = instance['instance_type']
421
436
            i['launchTime'] = instance['created_at']
422
437
            i['amiLaunchIndex'] = instance['launch_index']
 
438
            i['displayName'] = instance['display_name']
 
439
            i['displayDescription'] = instance['display_description']
423
440
            if not reservations.has_key(instance['reservation_id']):
424
441
                r = {}
425
442
                r['reservationId'] = instance['reservation_id']
577
594
        base_options['user_data'] = kwargs.get('user_data', '')
578
595
        base_options['security_group'] = security_group
579
596
        base_options['instance_type'] = instance_type
 
597
        base_options['display_name'] = kwargs.get('display_name')
 
598
        base_options['display_description'] = kwargs.get('display_description')
580
599
 
581
600
        type_data = INSTANCE_TYPES[instance_type]
582
601
        base_options['memory_mb'] = type_data['memory_mb']
673
692
                               "instance_id": instance_ref['id']}})
674
693
        return True
675
694
 
 
695
    def update_instance(self, context, instance_id, **kwargs):
 
696
        updatable_fields = ['display_name', 'display_description']
 
697
        changes = {}
 
698
        for field in updatable_fields:
 
699
            if field in kwargs:
 
700
                changes[field] = kwargs[field]
 
701
        if changes:
 
702
            db_context = {}
 
703
            inst = db.instance_get_by_ec2_id(db_context, instance_id)
 
704
            db.instance_update(db_context, inst['id'], kwargs)
 
705
        return True
 
706
 
676
707
    def delete_volume(self, context, volume_id, **kwargs):
677
708
        # TODO: return error if not authorized
678
709
        volume_ref = db.volume_get_by_ec2_id(context, volume_id)
728
759
        if not operation_type in ['add', 'remove']:
729
760
            raise exception.ApiError('operation_type must be add or remove')
730
761
        return images.modify(context, image_id, operation_type)
 
762
 
 
763
    def update_image(self, context, image_id, **kwargs):
 
764
        result = images.update(context, image_id, dict(kwargs))
 
765
        return result