Skip to content

Commit

Permalink
Merge pull request #51 from huangpeng5/cinder_930
Browse files Browse the repository at this point in the history
Openstack Cinder、Manila 2.6.2 Version
  • Loading branch information
yunqifeng authored Oct 11, 2023
2 parents b16d9c2 + 0c35321 commit 5ef31d8
Show file tree
Hide file tree
Showing 111 changed files with 2,823 additions and 917 deletions.
56 changes: 48 additions & 8 deletions Cinder/Mitaka/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def update_config_value(self):
self._replication_pair_sync_speed,
self._get_local_minimum_fc_initiator,
self._hyper_enforce_multipath,
self._get_local_in_band_or_not,
self._get_local_storage_sn,
self._rollback_speed)

tree = ET.parse(self.conf.cinder_huawei_conf_file,
Expand All @@ -103,14 +105,8 @@ def update_config_value(self):
for f in set_attr_funcs:
f(xml_root)

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
if text:
setattr(self.conf, 'ssl_cert_path', text)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
@staticmethod
def _get_ssl_verify(xml_root):
value = False
text = xml_root.findtext('Storage/SSLCertVerify')
if text:
Expand All @@ -120,7 +116,22 @@ def _ssl_cert_verify(self, xml_root):
msg = _("SSLCertVerify configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
return value

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
ssl_value = self._get_ssl_verify(xml_root)
if text and ssl_value:
setattr(self.conf, 'ssl_cert_path', text)
elif not text and ssl_value:
msg = _("Cert path is necessary if SSLCertVerify is True.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
value = self._get_ssl_verify(xml_root)
setattr(self.conf, 'ssl_cert_verify', value)

def _san_address(self, xml_root):
Expand Down Expand Up @@ -468,6 +479,10 @@ def get_hypermetro_devices(self):
dev_config['metro_sync_completed'] = (
dev['metro_sync_completed']
if 'metro_sync_completed' in dev else "True")
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -494,6 +509,10 @@ def get_replication_devices(self):
dev['iscsi_default_target_ip'].split(';')
if 'iscsi_default_target_ip' in dev
else [])
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -509,6 +528,8 @@ def get_local_device(self):
'iscsi_info': self.conf.iscsi_info,
'fc_info': self.conf.fc_info,
'iscsi_default_target_ip': self.conf.iscsi_default_target_ip,
'in_band_or_not': self.conf.in_band_or_not,
'storage_sn': self.conf.storage_sn,
}
return dev_config

Expand Down Expand Up @@ -611,6 +632,25 @@ def _get_local_minimum_fc_initiator(self, xml_root):
raise exception.InvalidInput(reason=msg)
setattr(self.conf, 'min_fc_ini_online', minimum_fc_initiator)

def _get_local_in_band_or_not(self, xml_root):
in_band_or_not = False
text = xml_root.findtext('Storage/InBandOrNot')
if text:
if text.lower() in ('true', 'false'):
in_band_or_not = text.lower() == 'true'
else:
msg = _("InBandOrNot configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

setattr(self.conf, 'in_band_or_not', in_band_or_not)

def _get_local_storage_sn(self, xml_root):
text = xml_root.findtext('Storage/Storagesn')
storage_sn = text.strip() if text else None

setattr(self.conf, 'storage_sn', storage_sn)

def _rollback_speed(self, xml_root):
text = xml_root.findtext('LUN/SnapshotRollbackSpeed')
if text and text.strip() not in constants.SNAPSHOT_ROLLBACK_SPEED_TYPES:
Expand Down
21 changes: 16 additions & 5 deletions Cinder/Mitaka/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,18 @@ def __init__(self, configuration, san_address, san_user, san_password,
self.url = None
self.ssl_cert_verify = self.configuration.ssl_cert_verify
self.ssl_cert_path = self.configuration.ssl_cert_path
self.in_band_or_not = kwargs.get('in_band_or_not',
self.configuration.in_band_or_not)
self.storage_sn = kwargs.get('storage_sn',
self.configuration.storage_sn)
self.is_dorado_v6 = False

if self.in_band_or_not and not self.storage_sn:
msg = _("'Storagesn' is must be set if 'InBandOrNot' is True,"
" Please Check Your config")
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)

if not self.ssl_cert_verify and hasattr(requests, 'packages'):
LOG.warning("Suppressing requests library SSL Warnings")
requests.packages.urllib3.disable_warnings(
Expand All @@ -82,13 +92,14 @@ def __init__(self, configuration, san_address, san_user, san_password,
def init_http_head(self):
self.url = None
self.session = requests.Session()
self.session.headers.update({
session_headers = {
"Connection": "keep-alive",
"Content-Type": "application/json"})
self.session.verify = False
"Content-Type": "application/json"}
if self.in_band_or_not:
session_headers["IBA-Target-Array"] = self.storage_sn
self.session.headers.update(session_headers)

if self.ssl_cert_verify:
self.session.verify = self.ssl_cert_path
self.session.verify = self.ssl_cert_path if self.ssl_cert_verify else False

def do_call(self, url=None, data=None, method=None,
calltimeout=constants.SOCKET_TIMEOUT, filter_flag=False):
Expand Down
56 changes: 48 additions & 8 deletions Cinder/Newton/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def update_config_value(self):
self._replication_pair_sync_speed,
self._get_local_minimum_fc_initiator,
self._hyper_enforce_multipath,
self._get_local_in_band_or_not,
self._get_local_storage_sn,
self._rollback_speed)

tree = ET.parse(self.conf.cinder_huawei_conf_file,
Expand All @@ -103,14 +105,8 @@ def update_config_value(self):
for f in set_attr_funcs:
f(xml_root)

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
if text:
setattr(self.conf, 'ssl_cert_path', text)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
@staticmethod
def _get_ssl_verify(xml_root):
value = False
text = xml_root.findtext('Storage/SSLCertVerify')
if text:
Expand All @@ -120,7 +116,22 @@ def _ssl_cert_verify(self, xml_root):
msg = _("SSLCertVerify configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
return value

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
ssl_value = self._get_ssl_verify(xml_root)
if text and ssl_value:
setattr(self.conf, 'ssl_cert_path', text)
elif not text and ssl_value:
msg = _("Cert path is necessary if SSLCertVerify is True.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
value = self._get_ssl_verify(xml_root)
setattr(self.conf, 'ssl_cert_verify', value)

def _san_address(self, xml_root):
Expand Down Expand Up @@ -468,6 +479,10 @@ def get_hypermetro_devices(self):
dev_config['metro_sync_completed'] = (
dev['metro_sync_completed']
if 'metro_sync_completed' in dev else "True")
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -494,6 +509,10 @@ def get_replication_devices(self):
dev['iscsi_default_target_ip'].split(';')
if 'iscsi_default_target_ip' in dev
else [])
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -509,6 +528,8 @@ def get_local_device(self):
'iscsi_info': self.conf.iscsi_info,
'fc_info': self.conf.fc_info,
'iscsi_default_target_ip': self.conf.iscsi_default_target_ip,
'in_band_or_not': self.conf.in_band_or_not,
'storage_sn': self.conf.storage_sn,
}
return dev_config

Expand Down Expand Up @@ -611,6 +632,25 @@ def _get_local_minimum_fc_initiator(self, xml_root):
raise exception.InvalidInput(reason=msg)
setattr(self.conf, 'min_fc_ini_online', minimum_fc_initiator)

def _get_local_in_band_or_not(self, xml_root):
in_band_or_not = False
text = xml_root.findtext('Storage/InBandOrNot')
if text:
if text.lower() in ('true', 'false'):
in_band_or_not = text.lower() == 'true'
else:
msg = _("InBandOrNot configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

setattr(self.conf, 'in_band_or_not', in_band_or_not)

def _get_local_storage_sn(self, xml_root):
text = xml_root.findtext('Storage/Storagesn')
storage_sn = text.strip() if text else None

setattr(self.conf, 'storage_sn', storage_sn)

def _rollback_speed(self, xml_root):
text = xml_root.findtext('LUN/SnapshotRollbackSpeed')
if text and text.strip() not in constants.SNAPSHOT_ROLLBACK_SPEED_TYPES:
Expand Down
21 changes: 16 additions & 5 deletions Cinder/Newton/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,18 @@ def __init__(self, configuration, san_address, san_user, san_password,
self.url = None
self.ssl_cert_verify = self.configuration.ssl_cert_verify
self.ssl_cert_path = self.configuration.ssl_cert_path
self.in_band_or_not = kwargs.get('in_band_or_not',
self.configuration.in_band_or_not)
self.storage_sn = kwargs.get('storage_sn',
self.configuration.storage_sn)
self.is_dorado_v6 = False

if self.in_band_or_not and not self.storage_sn:
msg = _("'Storagesn' is must be set if 'InBandOrNot' is True,"
" Please Check Your config")
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)

if not self.ssl_cert_verify and hasattr(requests, 'packages'):
LOG.warning("Suppressing requests library SSL Warnings")
requests.packages.urllib3.disable_warnings(
Expand All @@ -82,13 +92,14 @@ def __init__(self, configuration, san_address, san_user, san_password,
def init_http_head(self):
self.url = None
self.session = requests.Session()
self.session.headers.update({
session_headers = {
"Connection": "keep-alive",
"Content-Type": "application/json"})
self.session.verify = False
"Content-Type": "application/json"}
if self.in_band_or_not:
session_headers["IBA-Target-Array"] = self.storage_sn
self.session.headers.update(session_headers)

if self.ssl_cert_verify:
self.session.verify = self.ssl_cert_path
self.session.verify = self.ssl_cert_path if self.ssl_cert_verify else False

def do_call(self, url=None, data=None, method=None,
calltimeout=constants.SOCKET_TIMEOUT, filter_flag=False):
Expand Down
56 changes: 48 additions & 8 deletions Cinder/Ocata/huawei_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ def update_config_value(self):
self._replication_pair_sync_speed,
self._get_local_minimum_fc_initiator,
self._hyper_enforce_multipath,
self._get_local_in_band_or_not,
self._get_local_storage_sn,
self._rollback_speed)

tree = ET.parse(self.conf.cinder_huawei_conf_file,
Expand All @@ -103,14 +105,8 @@ def update_config_value(self):
for f in set_attr_funcs:
f(xml_root)

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
if text:
setattr(self.conf, 'ssl_cert_path', text)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
@staticmethod
def _get_ssl_verify(xml_root):
value = False
text = xml_root.findtext('Storage/SSLCertVerify')
if text:
Expand All @@ -120,7 +116,22 @@ def _ssl_cert_verify(self, xml_root):
msg = _("SSLCertVerify configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
return value

def _ssl_cert_path(self, xml_root):
text = xml_root.findtext('Storage/SSLCertPath')
ssl_value = self._get_ssl_verify(xml_root)
if text and ssl_value:
setattr(self.conf, 'ssl_cert_path', text)
elif not text and ssl_value:
msg = _("Cert path is necessary if SSLCertVerify is True.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)
else:
setattr(self.conf, 'ssl_cert_path', None)

def _ssl_cert_verify(self, xml_root):
value = self._get_ssl_verify(xml_root)
setattr(self.conf, 'ssl_cert_verify', value)

def _san_address(self, xml_root):
Expand Down Expand Up @@ -468,6 +479,10 @@ def get_hypermetro_devices(self):
dev_config['metro_sync_completed'] = (
dev['metro_sync_completed']
if 'metro_sync_completed' in dev else "True")
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -494,6 +509,10 @@ def get_replication_devices(self):
dev['iscsi_default_target_ip'].split(';')
if 'iscsi_default_target_ip' in dev
else [])
dev_config['in_band_or_not'] = (
dev['in_band_or_not'].lower() == 'true'
if 'in_band_or_not' in dev else False)
dev_config['storage_sn'] = dev.get('storage_sn')
devs_config.append(dev_config)

return devs_config
Expand All @@ -509,6 +528,8 @@ def get_local_device(self):
'iscsi_info': self.conf.iscsi_info,
'fc_info': self.conf.fc_info,
'iscsi_default_target_ip': self.conf.iscsi_default_target_ip,
'in_band_or_not': self.conf.in_band_or_not,
'storage_sn': self.conf.storage_sn,
}
return dev_config

Expand Down Expand Up @@ -611,6 +632,25 @@ def _get_local_minimum_fc_initiator(self, xml_root):
raise exception.InvalidInput(reason=msg)
setattr(self.conf, 'min_fc_ini_online', minimum_fc_initiator)

def _get_local_in_band_or_not(self, xml_root):
in_band_or_not = False
text = xml_root.findtext('Storage/InBandOrNot')
if text:
if text.lower() in ('true', 'false'):
in_band_or_not = text.lower() == 'true'
else:
msg = _("InBandOrNot configured error.")
LOG.error(msg)
raise exception.InvalidInput(reason=msg)

setattr(self.conf, 'in_band_or_not', in_band_or_not)

def _get_local_storage_sn(self, xml_root):
text = xml_root.findtext('Storage/Storagesn')
storage_sn = text.strip() if text else None

setattr(self.conf, 'storage_sn', storage_sn)

def _rollback_speed(self, xml_root):
text = xml_root.findtext('LUN/SnapshotRollbackSpeed')
if text and text.strip() not in constants.SNAPSHOT_ROLLBACK_SPEED_TYPES:
Expand Down
Loading

0 comments on commit 5ef31d8

Please sign in to comment.