<s> from itertools import ifilter <EOL> from cinderclient . v1 import client as cinder_client <EOL> from cinderclient import exceptions as cinder_exc <EOL> from cloudferry . lib . base import storage <EOL> from cloudferry . lib . os . identity import keystone <EOL> from cloudferry . lib . os . storage import filters as cinder_filters <EOL> from cloudferry . lib . utils import filters <EOL> from cloudferry . lib . utils import log <EOL> from cloudferry . lib . utils import proxy_client <EOL> from cloudferry . lib . utils import retrying <EOL> from cloudferry . lib . utils import utils <EOL> import re <EOL> RE_EXTRACT_HOST = re . compile ( r'<STR_LIT>' ) <EOL> AVAILABLE = '<STR_LIT>' <EOL> IN_USE = "<STR_LIT>" <EOL> CINDER_VOLUME = "<STR_LIT>" <EOL> LOG = log . getLogger ( __name__ ) <EOL> ID = '<STR_LIT:id>' <EOL> DISPLAY_NAME = '<STR_LIT>' <EOL> PROJECT_ID = '<STR_LIT>' <EOL> STATUS = '<STR_LIT:status>' <EOL> TENANT_ID = '<STR_LIT>' <EOL> USER_ID = '<STR_LIT>' <EOL> DELETED = '<STR_LIT>' <EOL> HOST = '<STR_LIT:host>' <EOL> IGNORED_TBL_LIST = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> QUOTA_TABLES = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ) <EOL> SRC = '<STR_LIT:src>' <EOL> TABLE_UNIQ_KEYS = { <EOL> '<STR_LIT>' : [ '<STR_LIT:id>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT:key>' ] , <EOL> '<STR_LIT>' : [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:key>' ] , <EOL> } <EOL> VALID_STATUSES = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> MIGRATED_VOLUMES_METADATA_KEY = '<STR_LIT>' <EOL> class CinderStorage ( storage . Storage ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config , cloud ) : <EOL> super ( CinderStorage , self ) . __init__ ( config ) <EOL> self . ssh_host = config . cloud . ssh_host <EOL> self . mysql_host = config . mysql . db_host if config . mysql . db_host else self . ssh_host <EOL> self . cloud = cloud <EOL> self . identity_client = cloud . resources [ utils . IDENTITY_RESOURCE ] <EOL> self . mysql_connector = cloud . mysql_connector ( '<STR_LIT>' ) <EOL> self . volume_filter = None <EOL> self . filter_tenant_id = None <EOL> @ property <EOL> def cinder_client ( self ) : <EOL> return self . proxy ( self . get_client ( self . config ) , self . config ) <EOL> def get_client ( self , params = None , tenant = None ) : <EOL> params = params or self . config <EOL> return cinder_client . Client ( <EOL> params . cloud . user , <EOL> params . cloud . password , <EOL> tenant or params . cloud . tenant , <EOL> params . cloud . auth_url , <EOL> cacert = params . cloud . cacert , <EOL> insecure = params . cloud . insecure , <EOL> region_name = params . cloud . region <EOL> ) <EOL> def get_filter ( self ) : <EOL> if self . volume_filter is None : <EOL> with open ( self . config . migrate . filter_path , '<STR_LIT:r>' ) as f : <EOL> filter_yaml = filters . FilterYaml ( f ) <EOL> filter_yaml . read ( ) <EOL> self . volume_filter = cinder_filters . CinderFilters ( <EOL> self . cinder_client , filter_yaml ) <EOL> return self . volume_filter <EOL> def read_info ( self , target = '<STR_LIT>' , ** kwargs ) : <EOL> if target == '<STR_LIT>' : <EOL> return self . _read_info_volumes ( ** kwargs ) <EOL> if target == '<STR_LIT>' : <EOL> return self . _read_info_resources ( ** kwargs ) <EOL> def _read_info_resources ( self , ** kwargs ) : <EOL> res = dict ( ) <EOL> self . filter_tenant_id = kwargs . get ( '<STR_LIT>' , None ) <EOL> res [ '<STR_LIT>' ] = self . _read_info_quota ( ) <EOL> return res <EOL> def _read_info_volumes ( self , ** kwargs ) : <EOL> info = { utils . VOLUMES_TYPE : { } } <EOL> for vol in self . get_volumes_list ( search_opts = kwargs ) : <EOL> if vol . status not in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> continue <EOL> volume = self . convert_volume ( vol , self . config , self . cloud ) <EOL> snapshots = { } <EOL> if self . config . migrate . keep_volume_snapshots : <EOL> search_opts = { '<STR_LIT>' : volume [ '<STR_LIT:id>' ] } <EOL> for snap in self . get_snapshots_list ( search_opts = search_opts ) : <EOL> snapshot = self . convert_snapshot ( snap , <EOL> volume , <EOL> self . config ) <EOL> snapshots [ snapshot [ '<STR_LIT:id>' ] ] = snapshot <EOL> info [ utils . VOLUMES_TYPE ] [ vol . id ] = { utils . VOLUME_BODY : volume , <EOL> '<STR_LIT>' : snapshots , <EOL> utils . META_INFO : { <EOL> } } <EOL> if self . config . migrate . keep_volume_storage : <EOL> info [ '<STR_LIT>' ] = { utils . VOLUMES_TYPE : '<STR_LIT>' } <EOL> self . cloud . ssh_util . execute ( '<STR_LIT>' , <EOL> host_exec = self . mysql_host ) <EOL> for table_name , file_name in info [ '<STR_LIT>' ] . iteritems ( ) : <EOL> self . download_table_from_db_to_file ( table_name , file_name ) <EOL> return info <EOL> def _read_info_quota ( self ) : <EOL> admin_tenant_id = self . identity_client . get_tenant_id_by_name ( <EOL> self . config . cloud . tenant ) <EOL> service_tenant_id = self . identity_client . get_tenant_id_by_name ( <EOL> self . config . cloud . service_tenant ) <EOL> if self . cloud . position == '<STR_LIT:src>' and self . filter_tenant_id : <EOL> tmp_list = [ admin_tenant_id , service_tenant_id ] <EOL> tmp_list . extend ( self . filter_tenant_id ) <EOL> tmp_list = list ( set ( tmp_list ) ) <EOL> tenant_ids = [ tenant . id for tenant in <EOL> self . identity_client . get_tenants_list ( ) <EOL> if tenant . id in tmp_list ] <EOL> else : <EOL> tenant_ids = [ tenant . id for tenant in <EOL> self . identity_client . get_tenants_list ( ) <EOL> if tenant . id != service_tenant_id ] <EOL> quotas = [ ] <EOL> for tenant_id in tenant_ids : <EOL> quota = self . cinder_client . quotas . get ( tenant_id ) <EOL> quota_conv = self . convert_quota ( quota ) <EOL> quota_conv [ '<STR_LIT>' ] = tenant_id <EOL> quota_conv [ '<STR_LIT>' ] = self . identity_client . try_get_tenant_name_by_id ( tenant_id ) <EOL> quotas . append ( quota_conv ) <EOL> return quotas <EOL> def _deploy_quota ( self , quotas ) : <EOL> quotas_res = [ ] <EOL> for quota in quotas : <EOL> tenant_id = self . identity_client . get_tenant_id_by_name ( quota [ '<STR_LIT>' ] ) <EOL> quota_arg = { k : v for k , v in quota . items ( ) <EOL> if k not in [ '<STR_LIT>' , '<STR_LIT>' ] } <EOL> quota_defaults = self . convert_quota ( <EOL> self . cinder_client . quotas . defaults ( tenant_id ) ) <EOL> quota_res = { k : quota_arg [ k ] for k in list ( set ( quota_arg ) & <EOL> set ( quota_defaults ) ) } <EOL> quota_obj = self . convert_quota ( <EOL> self . cinder_client . quotas . update ( tenant_id , ** quota_res ) ) <EOL> quotas_res . append ( quota_obj ) <EOL> return quotas_res <EOL> def _deploy_resources ( self , info ) : <EOL> res = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : self . _deploy_quota ( info [ '<STR_LIT>' ] ) <EOL> } <EOL> } <EOL> return res <EOL> def deploy ( self , info , target = '<STR_LIT>' , * args , ** kwargs ) : <EOL> if target == '<STR_LIT>' : <EOL> return self . _deploy_resources ( info ) <EOL> if target == '<STR_LIT>' : <EOL> return self . deploy_volumes ( info ) <EOL> def attach_volume_to_instance ( self , volume_info ) : <EOL> if '<STR_LIT>' in volume_info [ utils . META_INFO ] : <EOL> if volume_info [ utils . META_INFO ] [ '<STR_LIT>' ] : <EOL> self . attach_volume ( <EOL> volume_info [ utils . VOLUME_BODY ] [ '<STR_LIT:id>' ] , <EOL> volume_info [ utils . META_INFO ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , <EOL> volume_info [ utils . VOLUME_BODY ] [ '<STR_LIT>' ] ) <EOL> def filter_volumes ( self , volumes ) : <EOL> filtering_enabled = self . cloud . position == SRC <EOL> if filtering_enabled : <EOL> flts = self . get_filter ( ) . get_filters ( ) <EOL> for f in flts : <EOL> volumes = ifilter ( f , volumes ) <EOL> volumes = list ( volumes ) <EOL> def get_name ( volume ) : <EOL> if isinstance ( volume , dict ) : <EOL> return volume . get ( DISPLAY_NAME , volume [ '<STR_LIT:id>' ] ) <EOL> return getattr ( volume , DISPLAY_NAME , None ) or volume . id <EOL> LOG . info ( "<STR_LIT>" , <EOL> "<STR_LIT:U+002CU+0020>" . join ( ( str ( get_name ( i ) ) for i in volumes ) ) ) <EOL> return [ vol for vol in volumes <EOL> if cinder_filters . CinderFilters . get_col ( vol , '<STR_LIT:status>' ) . lower ( ) <EOL> in VALID_STATUSES ] <EOL> def get_volumes_list ( self , detailed = True , search_opts = None ) : <EOL> search_opts = search_opts or { } <EOL> search_opts [ '<STR_LIT>' ] = <NUM_LIT:1> <EOL> volumes = self . cinder_client . volumes . list ( detailed , search_opts ) <EOL> volumes = self . filter_volumes ( volumes ) <EOL> return volumes <EOL> def get_migrated_volume ( self , volume_id ) : <EOL> """<STR_LIT>""" <EOL> for v in self . get_volumes_list ( ) : <EOL> if v . metadata . get ( MIGRATED_VOLUMES_METADATA_KEY ) == volume_id : <EOL> return v <EOL> def get_snapshots_list ( self , detailed = True , search_opts = None ) : <EOL> return self . cinder_client . volume_snapshots . list ( detailed , search_opts ) <EOL> def create_snapshot ( self , volume_id , force = False , <EOL> display_name = None , display_description = None ) : <EOL> return self . cinder_client . volume_snapshots . create ( volume_id , <EOL> force , <EOL> display_name , <EOL> display_description ) <EOL> def create_volume_from_volume ( self , volume , tenant_id ) : <EOL> """<STR_LIT>""" <EOL> glance = self . cloud . resources [ utils . IMAGE_RESOURCE ] <EOL> compute = self . cloud . resources [ utils . COMPUTE_RESOURCE ] <EOL> az_mapper = compute . attr_override <EOL> metadata = volume . get ( '<STR_LIT>' , { } ) <EOL> metadata [ MIGRATED_VOLUMES_METADATA_KEY ] = volume [ '<STR_LIT:id>' ] <EOL> image_id = None <EOL> if volume [ '<STR_LIT>' ] : <EOL> image_metadata = volume [ '<STR_LIT>' ] <EOL> dst_image = glance . get_matching_image ( <EOL> uuid = image_metadata [ '<STR_LIT>' ] , <EOL> size = image_metadata [ '<STR_LIT:size>' ] , <EOL> name = image_metadata [ '<STR_LIT>' ] , <EOL> checksum = image_metadata [ '<STR_LIT>' ] ) <EOL> if dst_image : <EOL> image_id = dst_image . id <EOL> src_az = compute . get_availability_zone ( volume [ '<STR_LIT>' ] ) <EOL> created_volume = self . create_volume ( <EOL> size = volume [ '<STR_LIT:size>' ] , <EOL> project_id = tenant_id , <EOL> display_name = volume [ '<STR_LIT>' ] , <EOL> display_description = volume [ '<STR_LIT>' ] , <EOL> availability_zone = src_az or az_mapper . get_attr ( <EOL> volume , '<STR_LIT>' ) , <EOL> metadata = metadata , <EOL> imageRef = image_id ) <EOL> timeout = self . config . migrate . storage_backend_timeout <EOL> retryer = retrying . Retry ( max_time = timeout , <EOL> predicate = lambda v : v . status == '<STR_LIT>' , <EOL> predicate_retval_as_arg = True , <EOL> retry_message = "<STR_LIT>" ) <EOL> retryer . run ( self . get_volume_by_id , created_volume . id ) <EOL> return created_volume <EOL> def create_volume ( self , size , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> cinder = self . cinder_client <EOL> tenant_id = kwargs . get ( '<STR_LIT>' ) <EOL> if tenant_id : <EOL> identity = self . cloud . resources [ utils . IDENTITY_RESOURCE ] <EOL> ks = identity . keystone_client <EOL> user = self . config . cloud . user <EOL> with keystone . AddAdminUserToNonAdminTenant ( ks , user , tenant_id ) : <EOL> tenant = ks . tenants . get ( tenant_id ) <EOL> cinder = self . proxy ( self . get_client ( tenant = tenant . name ) , <EOL> self . config ) <EOL> with proxy_client . expect_exception ( cinder_exc . OverLimit ) : <EOL> return cinder . volumes . create ( size , ** kwargs ) <EOL> else : <EOL> with proxy_client . expect_exception ( cinder_exc . OverLimit ) : <EOL> return cinder . volumes . create ( size , ** kwargs ) <EOL> def delete_volume ( self , volume_id ) : <EOL> volume = self . get_volume_by_id ( volume_id ) <EOL> self . cinder_client . volumes . delete ( volume ) <EOL> def get_volume_by_id ( self , volume_id ) : <EOL> return self . cinder_client . volumes . get ( volume_id ) <EOL> def update_volume ( self , volume_id , ** kwargs ) : <EOL> volume = self . get_volume_by_id ( volume_id ) <EOL> return self . cinder_client . volumes . update ( volume , ** kwargs ) <EOL> def attach_volume ( self , volume_id , instance_id , mountpoint , mode = '<STR_LIT>' ) : <EOL> volume = self . get_volume_by_id ( volume_id ) <EOL> return self . cinder_client . volumes . attach ( volume , <EOL> instance_uuid = instance_id , <EOL> mountpoint = mountpoint , <EOL> mode = mode ) <EOL> def detach_volume ( self , volume_id ) : <EOL> return self . cinder_client . volumes . detach ( volume_id ) <EOL> def finish ( self , vol ) : <EOL> try : <EOL> with proxy_client . expect_exception ( cinder_exc . BadRequest ) : <EOL> self . cinder_client . volumes . set_bootable ( <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT:id>' ] , <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT>' ] ) <EOL> except cinder_exc . BadRequest : <EOL> LOG . info ( "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT:id>' ] ) <EOL> self . __patch_option_bootable_of_volume ( <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT:id>' ] , <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT>' ] ) <EOL> def upload_volume_to_image ( self , volume_id , force , image_name , <EOL> container_format , disk_format ) : <EOL> volume = self . get_volume_by_id ( volume_id ) <EOL> resp , image = self . cinder_client . volumes . upload_to_image ( <EOL> volume = volume , <EOL> force = force , <EOL> image_name = image_name , <EOL> container_format = container_format , <EOL> disk_format = disk_format ) <EOL> return resp , image [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> def get_status ( self , resource_id ) : <EOL> return self . cinder_client . volumes . get ( resource_id ) . status <EOL> def deploy_volumes ( self , info ) : <EOL> new_ids = { } <EOL> for vol_id , vol in info [ utils . VOLUMES_TYPE ] . iteritems ( ) : <EOL> vol_for_deploy = self . convert_to_params ( vol ) <EOL> volume = self . create_volume ( ** vol_for_deploy ) <EOL> vol [ utils . VOLUME_BODY ] [ '<STR_LIT:id>' ] = volume . id <EOL> timeout = self . config . migrate . storage_backend_timeout <EOL> self . try_wait_for_status ( volume . id , self . get_status , AVAILABLE , <EOL> timeout = timeout ) <EOL> self . finish ( vol ) <EOL> new_ids [ volume . id ] = vol_id <EOL> return new_ids <EOL> @ staticmethod <EOL> def convert_quota ( quota ) : <EOL> reprkeys = sorted ( k <EOL> for k in quota . __dict__ . keys ( ) <EOL> if k [ <NUM_LIT:0> ] != '<STR_LIT:_>' and k != '<STR_LIT>' ) <EOL> quota_conv = { } <EOL> for k in reprkeys : <EOL> quota_conv [ k ] = quota . __dict__ [ k ] <EOL> return quota_conv <EOL> @ staticmethod <EOL> def convert_volume ( vol , cfg , cloud ) : <EOL> compute = cloud . resources [ utils . COMPUTE_RESOURCE ] <EOL> volume = { <EOL> '<STR_LIT:id>' : vol . id , <EOL> '<STR_LIT:size>' : vol . size , <EOL> '<STR_LIT>' : vol . display_name , <EOL> '<STR_LIT>' : vol . display_description , <EOL> '<STR_LIT>' : ( <EOL> None if vol . volume_type == u'<STR_LIT:None>' else vol . volume_type ) , <EOL> '<STR_LIT>' : vol . availability_zone , <EOL> '<STR_LIT>' : vol . attachments [ <NUM_LIT:0> ] [ <EOL> '<STR_LIT>' ] if vol . attachments else None , <EOL> '<STR_LIT>' : vol . bootable . lower ( ) == '<STR_LIT:true>' , <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT:host>' : None , <EOL> '<STR_LIT:path>' : None , <EOL> '<STR_LIT>' : getattr ( vol , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : vol . metadata <EOL> } <EOL> if '<STR_LIT>' in vol . __dict__ : <EOL> volume [ '<STR_LIT>' ] = { <EOL> '<STR_LIT>' : vol . volume_image_metadata [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : vol . volume_image_metadata [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : vol . volume_image_metadata . get ( '<STR_LIT>' ) , <EOL> '<STR_LIT:size>' : int ( vol . volume_image_metadata . get ( '<STR_LIT:size>' , <NUM_LIT:0> ) ) <EOL> } <EOL> if cfg . storage . backend == utils . CEPH : <EOL> volume [ '<STR_LIT:path>' ] = "<STR_LIT>" % ( <EOL> cfg . storage . rbd_pool , cfg . storage . volume_name_template , vol . id ) <EOL> volume [ '<STR_LIT:host>' ] = ( cfg . storage . host <EOL> if cfg . storage . host <EOL> else cfg . cloud . ssh_host ) <EOL> elif vol . attachments and ( cfg . storage . backend == utils . ISCSI ) : <EOL> instance = compute . read_info ( <EOL> search_opts = { '<STR_LIT:id>' : vol . attachments [ <NUM_LIT:0> ] [ '<STR_LIT>' ] } ) <EOL> instance = instance [ utils . INSTANCES_TYPE ] <EOL> instance_info = instance . values ( ) [ <NUM_LIT:0> ] [ utils . INSTANCE_BODY ] <EOL> volume [ '<STR_LIT:host>' ] = instance_info [ '<STR_LIT:host>' ] <EOL> list_disk = utils . get_libvirt_block_info ( <EOL> instance_info [ '<STR_LIT>' ] , <EOL> cfg . cloud . ssh_host , <EOL> instance_info [ '<STR_LIT:host>' ] , <EOL> cfg . cloud . ssh_user , <EOL> cfg . cloud . ssh_sudo_password ) <EOL> volume [ '<STR_LIT:path>' ] = utils . find_element_by_in ( list_disk , vol . id ) <EOL> return volume <EOL> @ staticmethod <EOL> def convert_snapshot ( snap , volume , cfg ) : <EOL> snapshot = { <EOL> '<STR_LIT:id>' : snap . id , <EOL> '<STR_LIT>' : snap . volume_id , <EOL> '<STR_LIT>' : snap . project_id , <EOL> '<STR_LIT>' : snap . display_name , <EOL> '<STR_LIT>' : snap . display_description , <EOL> '<STR_LIT>' : snap . created_at , <EOL> '<STR_LIT:size>' : snap . size , <EOL> '<STR_LIT>' : volume [ '<STR_LIT:path>' ] <EOL> } <EOL> if cfg . storage . backend == utils . CEPH : <EOL> snapshot [ '<STR_LIT:name>' ] = "<STR_LIT>" % ( cfg . storage . snapshot_name_template , <EOL> snap . id ) <EOL> snapshot [ '<STR_LIT:path>' ] = "<STR_LIT>" % ( snapshot [ '<STR_LIT>' ] , <EOL> snapshot [ '<STR_LIT:name>' ] ) <EOL> snapshot [ '<STR_LIT:host>' ] = ( cfg . storage . host <EOL> if cfg . storage . host <EOL> else cfg . cloud . ssh_host ) <EOL> return snapshot <EOL> @ staticmethod <EOL> def convert_to_params ( vol ) : <EOL> volume_body = vol [ utils . VOLUME_BODY ] <EOL> info = { <EOL> '<STR_LIT:size>' : volume_body [ '<STR_LIT:size>' ] , <EOL> '<STR_LIT>' : volume_body [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : volume_body [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : volume_body [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : volume_body [ '<STR_LIT>' ] , <EOL> } <EOL> if '<STR_LIT:image>' in vol [ utils . META_INFO ] : <EOL> if vol [ utils . META_INFO ] [ '<STR_LIT:image>' ] : <EOL> info [ '<STR_LIT>' ] = vol [ utils . META_INFO ] [ '<STR_LIT:image>' ] [ '<STR_LIT:id>' ] <EOL> return info <EOL> def __patch_option_bootable_of_volume ( self , volume_id , bootable ) : <EOL> cmd = ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % ( int ( bootable ) , volume_id ) <EOL> self . mysql_connector . execute ( cmd ) <EOL> def download_table_from_db_to_file ( self , table_name , file_name ) : <EOL> self . mysql_connector . execute ( "<STR_LIT>" % <EOL> ( table_name , file_name ) ) <EOL> def upload_table_to_db ( self , table_name , file_name ) : <EOL> self . mysql_connector . execute ( "<STR_LIT>" % <EOL> ( file_name , table_name ) ) <EOL> def update_column_with_condition ( self , table_name , column , <EOL> old_value , new_value ) : <EOL> self . mysql_connector . execute ( "<STR_LIT>" % <EOL> ( table_name , column , new_value , column , <EOL> old_value ) ) <EOL> def update_column ( self , table_name , column_name , new_value ) : <EOL> self . mysql_connector . execute ( "<STR_LIT>" % <EOL> ( table_name , column_name , new_value ) ) <EOL> def get_volume_path_iscsi ( self , vol_id ) : <EOL> cmd = "<STR_LIT>" % vol_id <EOL> result = self . cloud . mysql_connector . execute ( cmd ) <EOL> if not result : <EOL> raise Exception ( '<STR_LIT>' <EOL> '<STR_LIT>' % vol_id ) <EOL> provider_location = result . fetchone ( ) [ <NUM_LIT:0> ] <EOL> provider_location_list = provider_location . split ( ) <EOL> iscsi_target_id = provider_location_list [ <NUM_LIT:1> ] <EOL> lun = provider_location_list [ <NUM_LIT:2> ] <EOL> ip = provider_location_list [ <NUM_LIT:0> ] . split ( '<STR_LIT:U+002C>' ) [ <NUM_LIT:0> ] <EOL> volume_path = '<STR_LIT>' % ( <EOL> ip , <EOL> iscsi_target_id , <EOL> lun ) <EOL> return volume_path </s>
