~ubuntu-branches/ubuntu/raring/cinder/raring

« back to all changes in this revision

Viewing changes to cinder/volume/rpcapi.py

  • Committer: Package Import Robot
  • Author(s): Chris J Arges
  • Date: 2013-01-15 10:10:28 UTC
  • mfrom: (7.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130115101028-i1jf2lyewii1xf2e
Tags: 2013.1~g2-0ubuntu2
debian/patches/series: Enable skip_failed_tests to fix FTBFS. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    API version history:
34
34
 
35
35
        1.0 - Initial version.
 
36
        1.1 - Adds clone volume option to create_volume.
 
37
        1.2 - Add publish_service_capabilities() method.
36
38
    '''
37
39
 
38
40
    BASE_RPC_API_VERSION = '1.0'
39
41
 
40
42
    def __init__(self):
41
 
        super(VolumeAPI, self).__init__(topic=FLAGS.volume_topic,
 
43
        super(VolumeAPI, self).__init__(
 
44
            topic=FLAGS.volume_topic,
42
45
            default_version=self.BASE_RPC_API_VERSION)
43
46
 
44
47
    def create_volume(self, ctxt, volume, host,
45
 
                      snapshot_id=None, image_id=None):
46
 
        self.cast(ctxt, self.make_msg('create_volume',
47
 
                                      volume_id=volume['id'],
48
 
                                      snapshot_id=snapshot_id,
49
 
                                      image_id=image_id),
50
 
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
48
                      snapshot_id=None, image_id=None,
 
49
                      source_volid=None):
 
50
        self.cast(ctxt,
 
51
                  self.make_msg('create_volume',
 
52
                                volume_id=volume['id'],
 
53
                                snapshot_id=snapshot_id,
 
54
                                image_id=image_id,
 
55
                                source_volid=source_volid),
 
56
                  topic=rpc.queue_get_for(ctxt,
 
57
                                          self.topic,
 
58
                                          host),
 
59
                  version='1.1')
51
60
 
52
61
    def delete_volume(self, ctxt, volume):
53
 
        self.cast(ctxt, self.make_msg('delete_volume',
54
 
                                      volume_id=volume['id']),
55
 
                topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
62
        self.cast(ctxt,
 
63
                  self.make_msg('delete_volume',
 
64
                                volume_id=volume['id']),
 
65
                  topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
56
66
 
57
67
    def create_snapshot(self, ctxt, volume, snapshot):
58
68
        self.cast(ctxt, self.make_msg('create_snapshot',
59
69
                                      volume_id=volume['id'],
60
70
                                      snapshot_id=snapshot['id']),
61
 
                topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
71
                  topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
62
72
 
63
73
    def delete_snapshot(self, ctxt, snapshot, host):
64
74
        self.cast(ctxt, self.make_msg('delete_snapshot',
65
75
                                      snapshot_id=snapshot['id']),
66
 
                topic=rpc.queue_get_for(ctxt, self.topic, host))
 
76
                  topic=rpc.queue_get_for(ctxt, self.topic, host))
67
77
 
68
78
    def attach_volume(self, ctxt, volume, instance_uuid, mountpoint):
69
79
        return self.call(ctxt, self.make_msg('attach_volume',
70
 
                                      volume_id=volume['id'],
71
 
                                      instance_uuid=instance_uuid,
72
 
                                      mountpoint=mountpoint),
73
 
                    topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
80
                                             volume_id=volume['id'],
 
81
                                             instance_uuid=instance_uuid,
 
82
                                             mountpoint=mountpoint),
 
83
                         topic=rpc.queue_get_for(ctxt,
 
84
                                                 self.topic,
 
85
                                                 volume['host']))
74
86
 
75
87
    def detach_volume(self, ctxt, volume):
76
88
        return self.call(ctxt, self.make_msg('detach_volume',
77
 
                                      volume_id=volume['id']),
78
 
                    topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
89
                                             volume_id=volume['id']),
 
90
                         topic=rpc.queue_get_for(ctxt,
 
91
                                                 self.topic,
 
92
                                                 volume['host']))
79
93
 
80
94
    def copy_volume_to_image(self, ctxt, volume, image_id):
81
95
        self.cast(ctxt, self.make_msg('copy_volume_to_image',
82
96
                                      volume_id=volume['id'],
83
97
                                      image_id=image_id),
84
 
                topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
98
                  topic=rpc.queue_get_for(ctxt,
 
99
                                          self.topic,
 
100
                                          volume['host']))
85
101
 
86
102
    def initialize_connection(self, ctxt, volume, connector):
87
103
        return self.call(ctxt, self.make_msg('initialize_connection',
88
 
                                      volume_id=volume['id'],
89
 
                                      connector=connector),
90
 
                    topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
104
                                             volume_id=volume['id'],
 
105
                                             connector=connector),
 
106
                         topic=rpc.queue_get_for(ctxt,
 
107
                                                 self.topic,
 
108
                                                 volume['host']))
91
109
 
92
110
    def terminate_connection(self, ctxt, volume, connector, force=False):
93
111
        return self.call(ctxt, self.make_msg('terminate_connection',
94
 
                                      volume_id=volume['id'],
95
 
                                      connector=connector,
96
 
                                      force=force),
97
 
                    topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
 
112
                                             volume_id=volume['id'],
 
113
                                             connector=connector,
 
114
                                             force=force),
 
115
                         topic=rpc.queue_get_for(ctxt,
 
116
                                                 self.topic,
 
117
                                                 volume['host']))
 
118
 
 
119
    def publish_service_capabilities(self, ctxt):
 
120
        self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities'),
 
121
                         version='1.2')