33
33
API version history:
35
35
1.0 - Initial version.
36
1.1 - Adds clone volume option to create_volume.
37
1.2 - Add publish_service_capabilities() method.
38
40
BASE_RPC_API_VERSION = '1.0'
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)
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,
50
topic=rpc.queue_get_for(ctxt, self.topic, host))
48
snapshot_id=None, image_id=None,
51
self.make_msg('create_volume',
52
volume_id=volume['id'],
53
snapshot_id=snapshot_id,
55
source_volid=source_volid),
56
topic=rpc.queue_get_for(ctxt,
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']))
63
self.make_msg('delete_volume',
64
volume_id=volume['id']),
65
topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
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']))
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))
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,
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,
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,
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'],
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,
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'],
97
topic=rpc.queue_get_for(ctxt, self.topic, volume['host']))
112
volume_id=volume['id'],
115
topic=rpc.queue_get_for(ctxt,
119
def publish_service_capabilities(self, ctxt):
120
self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities'),