TOPIC = CONF.volume_topic
BINARY = 'cinder-volume'
+ def _get_cctxt(self, host, version):
+ new_host = utils.get_volume_rpc_host(host)
+ return self.client.prepare(server=new_host, version=version)
+
def create_consistencygroup(self, ctxt, group, host):
- new_host = utils.extract_host(host)
- cctxt = self.client.prepare(server=new_host, version='1.26')
+ cctxt = self._get_cctxt(host, '1.26')
cctxt.cast(ctxt, 'create_consistencygroup',
group=group)
def delete_consistencygroup(self, ctxt, group):
- host = utils.extract_host(group.host)
- cctxt = self.client.prepare(server=host, version='1.26')
+ cctxt = self._get_cctxt(group.host, '1.26')
cctxt.cast(ctxt, 'delete_consistencygroup',
group=group)
def update_consistencygroup(self, ctxt, group, add_volumes=None,
remove_volumes=None):
- host = utils.extract_host(group.host)
- cctxt = self.client.prepare(server=host, version='1.26')
+ cctxt = self._get_cctxt(group.host, '1.26')
cctxt.cast(ctxt, 'update_consistencygroup',
group=group,
add_volumes=add_volumes,
def create_consistencygroup_from_src(self, ctxt, group, cgsnapshot=None,
source_cg=None):
- new_host = utils.extract_host(group.host)
- cctxt = self.client.prepare(server=new_host, version='1.31')
+ cctxt = self._get_cctxt(group.host, '1.31')
cctxt.cast(ctxt, 'create_consistencygroup_from_src',
group=group,
cgsnapshot=cgsnapshot,
source_cg=source_cg)
def create_cgsnapshot(self, ctxt, cgsnapshot):
- host = utils.extract_host(cgsnapshot.consistencygroup.host)
- cctxt = self.client.prepare(server=host, version='1.31')
+ cctxt = self._get_cctxt(cgsnapshot.consistencygroup.host, '1.31')
cctxt.cast(ctxt, 'create_cgsnapshot', cgsnapshot=cgsnapshot)
def delete_cgsnapshot(self, ctxt, cgsnapshot):
- new_host = utils.extract_host(cgsnapshot.consistencygroup.host)
- cctxt = self.client.prepare(server=new_host, version='1.31')
+ cctxt = self._get_cctxt(cgsnapshot.consistencygroup.host, '1.31')
cctxt.cast(ctxt, 'delete_cgsnapshot', cgsnapshot=cgsnapshot)
def create_volume(self, ctxt, volume, host, request_spec,
else:
version = '1.24'
- new_host = utils.extract_host(host)
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(host, version)
request_spec_p = jsonutils.to_primitive(request_spec)
cctxt.cast(ctxt, 'create_volume', **msg_args)
else:
version = '1.15'
- new_host = utils.extract_host(volume.host)
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(volume.host, version)
cctxt.cast(ctxt, 'delete_volume', **msg_args)
def create_snapshot(self, ctxt, volume, snapshot):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.20')
+ cctxt = self._get_cctxt(volume['host'], version='1.20')
cctxt.cast(ctxt, 'create_snapshot', volume_id=volume['id'],
snapshot=snapshot)
def delete_snapshot(self, ctxt, snapshot, host, unmanage_only=False):
- new_host = utils.extract_host(host)
- cctxt = self.client.prepare(server=new_host, version='1.20')
+ cctxt = self._get_cctxt(host, version='1.20')
cctxt.cast(ctxt, 'delete_snapshot', snapshot=snapshot,
unmanage_only=unmanage_only)
def attach_volume(self, ctxt, volume, instance_uuid, host_name,
mountpoint, mode):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.11')
+ cctxt = self._get_cctxt(volume['host'], '1.11')
return cctxt.call(ctxt, 'attach_volume',
volume_id=volume['id'],
instance_uuid=instance_uuid,
mode=mode)
def detach_volume(self, ctxt, volume, attachment_id):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.20')
+ cctxt = self._get_cctxt(volume['host'], '1.20')
return cctxt.call(ctxt, 'detach_volume', volume_id=volume['id'],
attachment_id=attachment_id)
def copy_volume_to_image(self, ctxt, volume, image_meta):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.3')
+ cctxt = self._get_cctxt(volume['host'], '1.3')
cctxt.cast(ctxt, 'copy_volume_to_image', volume_id=volume['id'],
image_meta=image_meta)
def initialize_connection(self, ctxt, volume, connector):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.0')
+ cctxt = self._get_cctxt(volume['host'], version='1.0')
return cctxt.call(ctxt, 'initialize_connection',
volume_id=volume['id'],
connector=connector)
def terminate_connection(self, ctxt, volume, connector, force=False):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.0')
+ cctxt = self._get_cctxt(volume['host'], version='1.0')
return cctxt.call(ctxt, 'terminate_connection', volume_id=volume['id'],
connector=connector, force=force)
def remove_export(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.30')
+ cctxt = self._get_cctxt(volume['host'], '1.30')
cctxt.cast(ctxt, 'remove_export', volume_id=volume['id'])
def publish_service_capabilities(self, ctxt):
cctxt.cast(ctxt, 'publish_service_capabilities')
def accept_transfer(self, ctxt, volume, new_user, new_project):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.9')
+ cctxt = self._get_cctxt(volume['host'], '1.9')
return cctxt.call(ctxt, 'accept_transfer', volume_id=volume['id'],
new_user=new_user, new_project=new_project)
def extend_volume(self, ctxt, volume, new_size, reservations):
- new_host = utils.extract_host(volume.host)
msg_args = {'volume_id': volume.id, 'new_size': new_size,
'reservations': reservations}
else:
version = '1.14'
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(volume.host, version)
cctxt.cast(ctxt, 'extend_volume', **msg_args)
def migrate_volume(self, ctxt, volume, dest_host, force_host_copy):
- new_host = utils.extract_host(volume.host)
host_p = {'host': dest_host.host,
'capabilities': dest_host.capabilities}
else:
version = '1.8'
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(volume.host, version)
cctxt.cast(ctxt, 'migrate_volume', **msg_args)
def migrate_volume_completion(self, ctxt, volume, new_volume, error):
- new_host = utils.extract_host(volume.host)
msg_args = {'volume_id': volume.id, 'new_volume_id': new_volume.id,
'error': error}
else:
version = '1.10'
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(volume.host, version)
return cctxt.call(ctxt, 'migrate_volume_completion', **msg_args)
def retype(self, ctxt, volume, new_type_id, dest_host,
else:
version = '1.12'
- new_host = utils.extract_host(volume.host)
- cctxt = self.client.prepare(server=new_host, version=version)
+ cctxt = self._get_cctxt(volume.host, version)
cctxt.cast(ctxt, 'retype', **msg_args)
def manage_existing(self, ctxt, volume, ref):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.15')
+ cctxt = self._get_cctxt(volume['host'], '1.15')
cctxt.cast(ctxt, 'manage_existing', volume_id=volume['id'], ref=ref)
def promote_replica(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.17')
+ cctxt = self._get_cctxt(volume['host'], '1.17')
cctxt.cast(ctxt, 'promote_replica', volume_id=volume['id'])
def reenable_replication(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.17')
+ cctxt = self._get_cctxt(volume['host'], '1.17')
cctxt.cast(ctxt, 'reenable_replication', volume_id=volume['id'])
def update_migrated_volume(self, ctxt, volume, new_volume,
original_volume_status):
- host = utils.extract_host(new_volume['host'])
- cctxt = self.client.prepare(server=host, version='1.36')
+ cctxt = self._get_cctxt(new_volume['host'], '1.36')
cctxt.call(ctxt,
'update_migrated_volume',
volume=volume,
volume_status=original_volume_status)
def enable_replication(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.27')
+ cctxt = self._get_cctxt(volume['host'], '1.27')
cctxt.cast(ctxt, 'enable_replication', volume=volume)
def disable_replication(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.27')
+ cctxt = self._get_cctxt(volume['host'], '1.27')
cctxt.cast(ctxt, 'disable_replication',
volume=volume)
ctxt,
volume,
secondary=None):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.27')
+ cctxt = self._get_cctxt(volume['host'], '1.27')
cctxt.cast(ctxt, 'failover_replication',
volume=volume,
secondary=secondary)
def list_replication_targets(self, ctxt, volume):
- new_host = utils.extract_host(volume['host'])
- cctxt = self.client.prepare(server=new_host, version='1.27')
+ cctxt = self._get_cctxt(volume['host'], '1.27')
return cctxt.call(ctxt, 'list_replication_targets', volume=volume)
def manage_existing_snapshot(self, ctxt, snapshot, ref, host):
- cctxt = self.client.prepare(server=host, version='1.28')
+ cctxt = self._get_cctxt(host, '1.28')
cctxt.cast(ctxt, 'manage_existing_snapshot',
snapshot=snapshot,
ref=ref)
def get_capabilities(self, ctxt, host, discover):
- new_host = utils.extract_host(host)
- cctxt = self.client.prepare(server=new_host, version='1.29')
+ cctxt = self._get_cctxt(host, '1.29')
return cctxt.call(ctxt, 'get_capabilities', discover=discover)