Skip to content

Commit

Permalink
Merge pull request #108 from dell/metro_dr_fix
Browse files Browse the repository at this point in the history
92/Metro DR fixes
  • Loading branch information
Michael McAleer authored Dec 14, 2020
2 parents c7ec31e + 2300d33 commit 0c8d85a
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 57 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
PyU4V Change Log
================

Version 9.2.0.4 - released 9/12/20
==================================
- Fix for metro_dr delete function
- Fix for metro_dr added recover option
- Fix for CI tests:
- PyU4V.tests.ci_tests.test_pyu4v_ci_system.CITestSystem._test_get_health_check_details
- PyU4V.tests.ci_tests.test_pyu4v_ci_system.CITestSystem.test_get_ip_interface_list
- PyU4V.tests.ci_tests.test_pyu4v_ci_system.CITestSystem.test_get_ip_interface
- Added Force Option to metro dr restore
- Application-Type header is now set by default to 'PyU4V-{version}'

Version 9.2.0.3 - released 7/12/20
==================================
- Masking View performance support has been added to performance.py
Expand Down
2 changes: 1 addition & 1 deletion PyU4V/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .univmax_conn import U4VConn # noqa: F401

__title__ = 'pyu4v'
__version__ = '9.2.0.3'
__version__ = '9.2.0.4'
__author__ = 'Dell EMC or its subsidiaries'
__license__ = 'Apache 2.0'
__copyright__ = 'Copyright 2020 Dell EMC Inc'
2 changes: 1 addition & 1 deletion PyU4V/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def delete_resource(self, *args, **kwargs):
target_uri = self._build_uri(*args, **kwargs)
message, status_code = self.request(
target_uri, DELETE, request_object=kwargs.get('payload'),
params=kwargs.get('payload'))
params=kwargs.get('params'))
resource_type = None
if args:
resource_type = args[2]
Expand Down
7 changes: 4 additions & 3 deletions PyU4V/metro_dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def convert_to_metrodr_environment(
return response

def delete_metrodr_environment(
self, environment_name, remove_r1_dr_rdfg=False,
self, environment_name, remove_r1_dr_rdfg=False, force=False,
metro_r1_array_id=None):
"""Deletes Metro DR Environment.
Expand All @@ -212,6 +212,7 @@ def delete_metrodr_environment(
characters-- str
:param remove_r1_dr_rdfg: override default behavior and delete R11-R2
RDFG from metro R1 side -- bool
:param force: required True if deleting R1 DR group -- bool
:param metro_r1_array_id: 12 Digit Serial of Metro R1 source
array -- str
"""
Expand All @@ -224,7 +225,7 @@ def delete_metrodr_environment(
category=REPLICATION, resource_level=SYMMETRIX,
resource_level_id=array_id, resource_type=METRO_DR,
resource_type_id=environment_name, params={
'remove_r1_dr_rdfg': remove_r1_dr_rdfg})
'remove_r1_dr_rdfg': remove_r1_dr_rdfg, 'force': force})

def modify_metrodr_environment(
self, environment_name, action, metro=False,
Expand Down Expand Up @@ -262,7 +263,7 @@ def modify_metrodr_environment(
else:
msg = (
'SRDF Action must be one of [Establish, Split, Suspend, '
'Restore, Resume, Failover, Failback, Update_R1, '
'Recover, Restore, Resume, Failover, Failback, Update_R1, '
'SetMode]')
LOG.exception(msg)
raise exception.VolumeBackendAPIException(data=msg)
Expand Down
1 change: 1 addition & 0 deletions PyU4V/tests/ci_tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setup_credentials(self):
"""Set REST credentials."""
self.conn = univmax_conn.U4VConn()
self.assertTrue(self.conn.rest_client.headers.get('user-agent'))
self.assertTrue(self.conn.rest_client.headers.get('application-type'))

def create_volume(self):
"""Create a test volume.
Expand Down
81 changes: 48 additions & 33 deletions PyU4V/tests/ci_tests/test_pyu4v_ci_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,11 @@ def _test_get_health_check_details(self):
health_check = self.system.get_health_check_details(
health_check_id=health_check_id)
self.assertIsInstance(health_check_list, dict)
run_checks = health_check.get(TEST_RES)
self.assertEqual(len(run_checks), 9)
run_checks = health_check.get(TEST_RES, list())
try:
self.assertEqual(len(run_checks), 9)
except AssertionError:
self.assertEqual(len(run_checks), 8)

def _test_delete_health_check(self):
"""Test delete_health_check."""
Expand Down Expand Up @@ -552,43 +555,55 @@ def test_get_director_port_list_iscsi_target_set(self):

def test_get_ip_interface_list(self):
"""Test get_ip_interface_list."""
found_ip_list = False

iscsi_dir_list = self.system.get_director_list(iscsi_only=True)
if not iscsi_dir_list:
self.skipTest('No iSCSI Directors available in CI environment.')
director_id = random.choice(iscsi_dir_list)

iscsi_port_list = self.system.get_director_port_list(
director_id=director_id, iscsi_target=False)
if not iscsi_port_list:
self.skipTest('No IP interface ports available in CI environment.')
port = random.choice(iscsi_port_list)
port_id = port.get('portId')

ip_interface_list = self.system.get_ip_interface_list(
director_id=director_id, port_id=port_id)
self.assertTrue(ip_interface_list)
self.assertIsInstance(ip_interface_list, list)
for dir_id in iscsi_dir_list:
port_list = self.system.get_director_port_list(
director_id=dir_id, iscsi_target=False)
if not port_list:
continue
for port in port_list:
port_id = port.get('portId')
ip_interface_list = self.system.get_ip_interface_list(
director_id=dir_id, port_id=port_id)
if not ip_interface_list:
continue

self.assertTrue(ip_interface_list)
self.assertIsInstance(ip_interface_list, list)
found_ip_list = True

if not found_ip_list:
self.skipTest('No IP interfaces available in CI environment.')

def test_get_ip_interface(self):
"""Test get_ip_interface."""
found_ip = False

iscsi_dir_list = self.system.get_director_list(iscsi_only=True)
if not iscsi_dir_list:
self.skipTest('No iSCSI Directors available in CI environment.')
director_id = random.choice(iscsi_dir_list)

iscsi_port_list = self.system.get_director_port_list(
director_id=director_id, iscsi_target=False)
if not iscsi_port_list:
self.skipTest('No IP interface ports available in CI environment.')
port = random.choice(iscsi_port_list)
port_id = port.get('portId')

ip_interface_list = self.system.get_ip_interface_list(
director_id=director_id, port_id=port_id)
ip_interface = random.choice(ip_interface_list)

ip_interface_details = self.system.get_ip_interface(
director_id=director_id, port_id=port_id,
interface_id=ip_interface)
self.assertTrue(ip_interface_details)
self.assertIsInstance(ip_interface_details, dict)
for dir_id in iscsi_dir_list:
port_list = self.system.get_director_port_list(
director_id=dir_id, iscsi_target=False)
if not port_list:
continue
for port in port_list:
port_id = port.get('portId')
ip_interface_list = self.system.get_ip_interface_list(
director_id=dir_id, port_id=port_id)
if not ip_interface_list:
continue

ip_interface_details = self.system.get_ip_interface(
director_id=dir_id, port_id=port_id,
interface_id=ip_interface_list[0])
self.assertTrue(ip_interface_details)
self.assertIsInstance(ip_interface_details, dict)
found_ip = True

if not found_ip:
self.skipTest('No IP interfaces available in CI environment.')
8 changes: 8 additions & 0 deletions PyU4V/tests/unit_tests/test_pyu4v_metro_dr.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,11 @@ def test_modify_metrodr_environment_restore_both(self):
exception.InvalidInputException,
self.metro_dr.modify_metrodr_environment, action='restore',
environment_name='PyU4V', metro=True, dr=True)

def test_modify_metrodr_environment_recover(self):
"""Test create_metrodr_environment."""
with mock.patch.object(
self.metro_dr, 'modify_resource') as mock_put:
self.metro_dr.modify_metrodr_environment(
action='recover', environment_name='PyU4V')
mock_put.assert_called_once()
20 changes: 13 additions & 7 deletions PyU4V/tests/unit_tests/test_pyu4v_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def setUp(self):
'PyU4V/{pv} ({plat}; version {rel}) Python {python}'.format(
pv=pyu4v_version, plat=sys_platform,
rel=sys_platform_release, python=python_version))
self.app_type = 'PyU4V-{v}'.format(v=pyu4v_version)
self.rest = rest_requests.RestRequests(
username='smc', password='smc', verify=False,
base_url='http://10.10.10.10:8443/univmax/restapi',
interval=1, retries=3, application_type='pyu4v')
interval=1, retries=3)

def test_rest_requests_init(self):
"""Test class RestRequests __init__."""
Expand All @@ -59,7 +60,7 @@ def test_rest_requests_init(self):
self.assertEqual(self.rest.timeout, 120)
ref_headers = {'content-type': 'application/json',
'accept': 'application/json',
'application-type': 'pyu4v',
'application-type': None,
'user-agent': self.ua_details}
self.assertEqual(self.rest.headers, ref_headers)
self.assertIsInstance(self.rest.session,
Expand All @@ -69,12 +70,17 @@ def test_establish_rest_session(self):
"""Test establish REST session."""
ref_headers = {'content-type': 'application/json',
'accept': 'application/json',
'application-type': 'pyu4v',
'application-type': 'test_app',
'user-agent': self.ua_details}
self.assertEqual(ref_headers, self.rest.session.headers)
self.assertEqual('smc', self.rest.session.auth.username)
self.assertEqual('smc', self.rest.session.auth.password)
self.assertEqual(False, self.rest.session.verify)
temp_rest = rest_requests.RestRequests(
username='smc', password='smc', verify=False,
base_url='http://10.10.10.10:8443/univmax/restapi',
interval=1, retries=3, application_type='test_app')

self.assertEqual(ref_headers, temp_rest.session.headers)
self.assertEqual('smc', temp_rest.session.auth.username)
self.assertEqual('smc', temp_rest.session.auth.password)
self.assertEqual(False, temp_rest.session.verify)

def test_establish_rest_session_with_headers(self):
"""Test establish_rest_session with headers."""
Expand Down
4 changes: 3 additions & 1 deletion PyU4V/univmax_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@


file_path = None
app_type = 'PyU4V-{v}'.format(v=constants.PYU4V_VERSION)

LOG = logging.getLogger(__name__)

SETUP = constants.SETUP
Expand All @@ -53,7 +55,7 @@ def __init__(self, username=None, password=None, server_ip=None,
port=None, verify=None,
u4v_version=constants.UNISPHERE_VERSION,
interval=5, retries=200, array_id=None,
application_type=None, remote_array=None,
application_type=app_type, remote_array=None,
remote_array_2=None):
"""__init__."""
config = config_handler.set_logger_and_config(file_path)
Expand Down
8 changes: 4 additions & 4 deletions PyU4V/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
APP_MPART = 'multipart/form-data'

# Unisphere REST URI constants
PYU4V_VERSION = '9.2.0.3'
PYU4V_VERSION = '9.2.0.4'
UNISPHERE_VERSION = '92'
VERSION = 'version'
ITERATOR = 'Iterator'
Expand Down Expand Up @@ -107,6 +107,7 @@
ESTABLISH = 'Establish'
FAILBACK = 'Failback'
FAILOVER = 'Failover'
RECOVER = 'Recover'
RESTORE = 'Restore'
RESUME = 'Resume'
SETBIAS = 'SetBias'
Expand All @@ -122,10 +123,9 @@
'REMOVE_PORTS': 'remove_ports', 'SET_LABEL': 'set_label'}
METRO_DR_ACTIONS = {
'ESTABLISH': ESTABLISH, 'SPLIT': SPLIT, 'SUSPEND': SUSPEND,
'RESTORE': RESTORE, 'FAILOVER': FAILOVER, 'FAILBACK': FAILBACK,
'SETMODE': SETMODE, 'UPDATER1': UPDATE_R1
'RECOVER': RECOVER, 'RESTORE': RESTORE, 'FAILOVER': FAILOVER,
'FAILBACK': FAILBACK, 'SETMODE': SETMODE, 'UPDATER1': UPDATE_R1
}

METRO_DR_ACTION_PARAMS = {
'ESTABLISH': 'establish', 'SPLIT': 'split', 'SUSPEND': 'suspend',
'RESTORE': 'restore', 'FAILOVER': 'failover',
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PyU4V Version 9.2
+-------------------------------+----------------------------+
| **Author** | Dell EMC |
+-------------------------------+----------------------------+
| **PyU4V Version** | 9.2.0.3 |
| **PyU4V Version** | 9.2.0.4 |
+-------------------------------+----------------------------+
| **Minimum Unisphere Version** | 9.2.0.1 |
+-------------------------------+----------------------------+
Expand Down Expand Up @@ -80,7 +80,7 @@ specifying ``PyU4V`` as the install package for ``pip``::

$ pip install PyU4V
# Install a specific version
$ pip install PyU4V==9.2.0.3
$ pip install PyU4V==9.2.0.4

Copy the sample ``PyU4V.conf`` provided with PyU4V to either your working
directory or within a directory named ``.PyU4V`` in your current users home
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# The short X.Y version.
version = u'9.2'
# The full version, including alpha/beta/rc tags
release = '9.2.0.3'
release = '9.2.0.4'

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Supported PyU4V Versions
------------------------

+-------------------------------+----------------------------------------+
| **PyU4V Version** | 9.2.0.3 |
| **PyU4V Version** | 9.2.0.4 |
+-------------------------------+----------------------------------------+
| **Minimum Unisphere Version** | 9.2.0.1 |
+-------------------------------+----------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Requirements
------------

+-------------------------------+----------------------------------------+
| **PyU4V Version** | 9.2.0.3 |
| **PyU4V Version** | 9.2.0.4 |
+-------------------------------+----------------------------------------+
| **Minimum Unisphere Version** | 9.2.0.1 |
+-------------------------------+----------------------------------------+
Expand Down Expand Up @@ -66,7 +66,7 @@ specifying ``PyU4V`` as the install package for ``pip``:
$ pip install PyU4V
# Install a specific version
$ pip install PyU4V==9.2.0.3
$ pip install PyU4V==9.2.0.4
.. URL LINKS
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setuptools.setup(
name='PyU4V',
version='9.2.0.3',
version='9.2.0.4',
url='https://github.com/dell/PyU4V/',
author='Dell Inc. or its subsidiaries',
author_email='[email protected]',
Expand Down

0 comments on commit 0c8d85a

Please sign in to comment.