sr_path=sr_path,
auth_token=auth_token)
+ def upload_vhd(self, vdi_uuids, image_id, glance_host, glance_port,
+ glance_use_ssl, sr_path, auth_token, properties):
+ return self.call(
+ 'upload_vhd',
+ vdi_uuids=vdi_uuids,
+ image_id=image_id,
+ glance_host=glance_host,
+ glance_port=glance_port,
+ glance_use_ssl=glance_use_ssl,
+ sr_path=sr_path,
+ auth_token=auth_token,
+ properties=properties)
+
class NFSBasedVolumeOperations(object):
def __init__(self, session_factory):
return False
return True
+
+ def use_glance_plugin_to_upload_volume(self, server, serverpath,
+ sr_uuid, vdi_uuid, glance_server,
+ image_id, auth_token, sr_base_path):
+ self.connect_volume(server, serverpath, sr_uuid, vdi_uuid)
+
+ vdi_uuids = [vdi_uuid]
+ glance_host, glance_port, glance_use_ssl = glance_server
+
+ try:
+ result = self.glance_plugin.upload_vhd(
+ vdi_uuids, image_id, glance_host, glance_port, glance_use_ssl,
+ os.path.join(sr_base_path, sr_uuid), auth_token, dict())
+ finally:
+ self.disconnect_volume(vdi_uuid)
volume['size'])
def copy_volume_to_image(self, context, volume, image_service, image_meta):
- raise NotImplementedError()
+ image_id = image_meta['id']
+
+ sr_uuid, vdi_uuid = volume['provider_location'].split('/')
+
+ api_servers = glance.get_api_servers()
+ glance_server = api_servers.next()
+ auth_token = context.auth_token
+
+ self.nfs_ops.use_glance_plugin_to_upload_volume(
+ FLAGS.xenapi_nfs_server,
+ FLAGS.xenapi_nfs_serverpath,
+ sr_uuid,
+ vdi_uuid,
+ glance_server,
+ image_id,
+ auth_token,
+ FLAGS.xenapi_sr_base_path)