Use IP in Kaminario locks and add/delete loggers
If some K2 arrays are configured with same 'volume_backend_name' in cinder.conf, then 'self.k2_lock_name' will be same for attaching and detaching volumes for these arrays and it will block simultaneous attach and detach volumes for these K2 arrays. Use of K2 management IP in place of 'volume_backend_name' will keep 'self.k2_lock_name' different for attaching and detaching volumes and allow simultaneous attach and detach volumes for these K2 arrays. Also, Adding/Deleting loggers according to below thumb rules: 1. startup/shutdown functions should use the logging decorator 2. each function that creates objects should use the logging decorator 3. helper functions that do not create objects should NOT use the logging decorator 4. API functions should use the logging decorator Change-Id: I1b70bee41f6c42585d0df40a4ae59c33f038b58c Closes-Bug: #1623328 Co-Authored-By: Ido Benda<Ido.Benda@kaminario.com>
This commit is contained in:
parent
2bc1cf9031
commit
a04ef2278a
@ -87,7 +87,6 @@ if krest:
|
|||||||
retries=MAX_K2_RETRY)
|
retries=MAX_K2_RETRY)
|
||||||
def _request(self, method, *args, **kwargs):
|
def _request(self, method, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
LOG.debug("running through the _request wrapper...")
|
|
||||||
self.krestlock.acquire()
|
self.krestlock.acquire()
|
||||||
return super(KrestWrap, self)._request(method,
|
return super(KrestWrap, self)._request(method,
|
||||||
*args, **kwargs)
|
*args, **kwargs)
|
||||||
@ -142,9 +141,10 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
self.configuration.append_config_values(kaminario2_opts)
|
self.configuration.append_config_values(kaminario2_opts)
|
||||||
self.replica = None
|
self.replica = None
|
||||||
self._protocol = None
|
self._protocol = None
|
||||||
k2_lock_sfx = self.configuration.safe_get('volume_backend_name') or ''
|
k2_lock_sfx = self.configuration.safe_get('san_ip')
|
||||||
self.k2_lock_name = "%s-%s" % (K2_LOCK_PREFIX, k2_lock_sfx)
|
self.k2_lock_name = "%s-%s" % (K2_LOCK_PREFIX, k2_lock_sfx)
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def check_for_setup_error(self):
|
def check_for_setup_error(self):
|
||||||
if krest is None:
|
if krest is None:
|
||||||
msg = _("Unable to import 'krest' python module.")
|
msg = _("Unable to import 'krest' python module.")
|
||||||
@ -177,7 +177,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.KaminarioCinderDriverException(reason=msg)
|
raise exception.KaminarioCinderDriverException(reason=msg)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def _check_ops(self):
|
def _check_ops(self):
|
||||||
"""Ensure that the options we care about are set."""
|
"""Ensure that the options we care about are set."""
|
||||||
required_ops = ['san_ip', 'san_login', 'san_password']
|
required_ops = ['san_ip', 'san_login', 'san_password']
|
||||||
@ -349,6 +348,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
raise exception.KaminarioCinderDriverException(
|
raise exception.KaminarioCinderDriverException(
|
||||||
reason=six.text_type(ex.message))
|
reason=six.text_type(ex.message))
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def _delete_by_ref(self, device, url, name, msg):
|
def _delete_by_ref(self, device, url, name, msg):
|
||||||
rs = device.search(url, name=name)
|
rs = device.search(url, name=name)
|
||||||
for result in rs.hits:
|
for result in rs.hits:
|
||||||
@ -522,6 +522,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
back_end_ip = self.replica.backend_id
|
back_end_ip = self.replica.backend_id
|
||||||
return back_end_ip, volume_updates
|
return back_end_ip, volume_updates
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def _create_volume_replica_user_snap(self, k2, sess):
|
def _create_volume_replica_user_snap(self, k2, sess):
|
||||||
snap = k2.new("snapshots")
|
snap = k2.new("snapshots")
|
||||||
snap.is_application_consistent = "False"
|
snap.is_application_consistent = "False"
|
||||||
@ -743,7 +744,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
for s in rsnaps:
|
for s in rsnaps:
|
||||||
s.delete()
|
s.delete()
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def _check_for_status(self, obj, status):
|
def _check_for_status(self, obj, status):
|
||||||
while obj.state != status:
|
while obj.state != status:
|
||||||
obj.refresh()
|
obj.refresh()
|
||||||
@ -819,7 +819,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
raise exception.KaminarioCinderDriverException(
|
raise exception.KaminarioCinderDriverException(
|
||||||
reason=six.text_type(ex.message))
|
reason=six.text_type(ex.message))
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def update_volume_stats(self):
|
def update_volume_stats(self):
|
||||||
conf = self.configuration
|
conf = self.configuration
|
||||||
LOG.debug("Searching system capacity in K2.")
|
LOG.debug("Searching system capacity in K2.")
|
||||||
@ -845,7 +844,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
'replication_enabled': True,
|
'replication_enabled': True,
|
||||||
'kaminario:replication': True}
|
'kaminario:replication': True}
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_initiator_host_name(self, connector):
|
def get_initiator_host_name(self, connector):
|
||||||
"""Return the initiator host name.
|
"""Return the initiator host name.
|
||||||
|
|
||||||
@ -855,32 +853,26 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
"""
|
"""
|
||||||
return re.sub('[^0-9a-zA-Z-_]', '_', connector.get('host', ''))[:32]
|
return re.sub('[^0-9a-zA-Z-_]', '_', connector.get('host', ''))[:32]
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_volume_group_name(self, vid):
|
def get_volume_group_name(self, vid):
|
||||||
"""Return the volume group name."""
|
"""Return the volume group name."""
|
||||||
return "cvg-{0}".format(vid)
|
return "cvg-{0}".format(vid)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_volume_name(self, vid):
|
def get_volume_name(self, vid):
|
||||||
"""Return the volume name."""
|
"""Return the volume name."""
|
||||||
return "cv-{0}".format(vid)
|
return "cv-{0}".format(vid)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_session_name(self, vid):
|
def get_session_name(self, vid):
|
||||||
"""Return the volume name."""
|
"""Return the volume name."""
|
||||||
return "ssn-{0}".format(vid)
|
return "ssn-{0}".format(vid)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_snap_name(self, sid):
|
def get_snap_name(self, sid):
|
||||||
"""Return the snapshot name."""
|
"""Return the snapshot name."""
|
||||||
return "cs-{0}".format(sid)
|
return "cs-{0}".format(sid)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_view_name(self, vid):
|
def get_view_name(self, vid):
|
||||||
"""Return the view name."""
|
"""Return the view name."""
|
||||||
return "cview-{0}".format(vid)
|
return "cview-{0}".format(vid)
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_rep_name(self, name):
|
def get_rep_name(self, name):
|
||||||
"""Return the corresponding replication names."""
|
"""Return the corresponding replication names."""
|
||||||
return "r{0}".format(name)
|
return "r{0}".format(name)
|
||||||
@ -893,7 +885,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
host = host_rs.hits[0]
|
host = host_rs.hits[0]
|
||||||
host.delete()
|
host.delete()
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_policy(self):
|
def get_policy(self):
|
||||||
"""Return the retention policy."""
|
"""Return the retention policy."""
|
||||||
try:
|
try:
|
||||||
@ -905,7 +896,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
raise exception.KaminarioCinderDriverException(
|
raise exception.KaminarioCinderDriverException(
|
||||||
reason=six.text_type(ex.message))
|
reason=six.text_type(ex.message))
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def _get_volume_object(self, volume):
|
def _get_volume_object(self, volume):
|
||||||
vol_name = self.get_volume_name(volume.id)
|
vol_name = self.get_volume_name(volume.id)
|
||||||
if volume.replication_status == K2_REP_FAILED_OVER:
|
if volume.replication_status == K2_REP_FAILED_OVER:
|
||||||
@ -918,7 +908,6 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
raise exception.KaminarioCinderDriverException(reason=msg)
|
raise exception.KaminarioCinderDriverException(reason=msg)
|
||||||
return vol_rs.hits[0]
|
return vol_rs.hits[0]
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def _get_lun_number(self, vol, host):
|
def _get_lun_number(self, vol, host):
|
||||||
volsnap = None
|
volsnap = None
|
||||||
LOG.debug("Searching volsnaps in K2.")
|
LOG.debug("Searching volsnaps in K2.")
|
||||||
@ -964,6 +953,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
else:
|
else:
|
||||||
LOG.warning(_LW("Host: %s not found on K2."), host_name)
|
LOG.warning(_LW("Host: %s not found on K2."), host_name)
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def k2_initialize_connection(self, volume, connector):
|
def k2_initialize_connection(self, volume, connector):
|
||||||
# Get volume object.
|
# Get volume object.
|
||||||
if type(volume).__name__ != 'RestObject':
|
if type(volume).__name__ != 'RestObject':
|
||||||
@ -1029,6 +1019,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def manage_existing(self, volume, existing_ref):
|
def manage_existing(self, volume, existing_ref):
|
||||||
vol_name = existing_ref['source-name']
|
vol_name = existing_ref['source-name']
|
||||||
new_name = self.get_volume_name(volume.id)
|
new_name = self.get_volume_name(volume.id)
|
||||||
@ -1068,6 +1059,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
existing_ref=existing_ref,
|
existing_ref=existing_ref,
|
||||||
reason=six.text_type(ex.message))
|
reason=six.text_type(ex.message))
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def manage_existing_get_size(self, volume, existing_ref):
|
def manage_existing_get_size(self, volume, existing_ref):
|
||||||
vol_name = existing_ref['source-name']
|
vol_name = existing_ref['source-name']
|
||||||
v_rs = self.client.search("volumes", name=vol_name)
|
v_rs = self.client.search("volumes", name=vol_name)
|
||||||
@ -1080,6 +1072,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
existing_ref=existing_ref,
|
existing_ref=existing_ref,
|
||||||
reason=_('Unable to get size of manage volume.'))
|
reason=_('Unable to get size of manage volume.'))
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def after_volume_copy(self, ctxt, volume, new_volume, remote=None):
|
def after_volume_copy(self, ctxt, volume, new_volume, remote=None):
|
||||||
self.delete_volume(volume)
|
self.delete_volume(volume)
|
||||||
vg_name_old = self.get_volume_group_name(volume.id)
|
vg_name_old = self.get_volume_group_name(volume.id)
|
||||||
@ -1093,6 +1086,7 @@ class KaminarioCinderDriver(cinder.volume.driver.ISCSIDriver):
|
|||||||
vol_new.name = vol_name_old
|
vol_new.name = vol_name_old
|
||||||
vol_new.save()
|
vol_new.save()
|
||||||
|
|
||||||
|
@kaminario_logger
|
||||||
def retype(self, ctxt, volume, new_type, diff, host):
|
def retype(self, ctxt, volume, new_type, diff, host):
|
||||||
old_type = volume.get('volume_type')
|
old_type = volume.get('volume_type')
|
||||||
vg_name = self.get_volume_group_name(volume.id)
|
vg_name = self.get_volume_group_name(volume.id)
|
||||||
|
@ -112,7 +112,6 @@ class KaminarioFCDriver(common.KaminarioCinderDriver):
|
|||||||
self.client = temp_client
|
self.client = temp_client
|
||||||
return properties
|
return properties
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_target_info(self, volume):
|
def get_target_info(self, volume):
|
||||||
LOG.debug("Searching target wwpns in K2.")
|
LOG.debug("Searching target wwpns in K2.")
|
||||||
fc_ports_rs = self.client.search("system/fc_ports")
|
fc_ports_rs = self.client.search("system/fc_ports")
|
||||||
@ -168,7 +167,6 @@ class KaminarioFCDriver(common.KaminarioCinderDriver):
|
|||||||
reason=six.text_type(ex.message))
|
reason=six.text_type(ex.message))
|
||||||
return host, host_rs, host_name
|
return host, host_rs, host_name
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def _build_initiator_target_map(self, connector, all_target_wwns):
|
def _build_initiator_target_map(self, connector, all_target_wwns):
|
||||||
"""Build the target_wwns and the initiator target map."""
|
"""Build the target_wwns and the initiator target map."""
|
||||||
target_wwns = []
|
target_wwns = []
|
||||||
|
@ -91,7 +91,6 @@ class KaminarioISCSIDriver(common.KaminarioCinderDriver):
|
|||||||
if temp_client:
|
if temp_client:
|
||||||
self.client = temp_client
|
self.client = temp_client
|
||||||
|
|
||||||
@kaminario_logger
|
|
||||||
def get_target_info(self, volume):
|
def get_target_info(self, volume):
|
||||||
LOG.debug("Searching first iscsi port ip without wan in K2.")
|
LOG.debug("Searching first iscsi port ip without wan in K2.")
|
||||||
iscsi_ip_rs = self.client.search("system/net_ips", wan_port="")
|
iscsi_ip_rs = self.client.search("system/net_ips", wan_port="")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user