Skip to content
This repository has been archived by the owner on Feb 24, 2022. It is now read-only.

Commit

Permalink
Sync bitbucket and Github
Browse files Browse the repository at this point in the history
  • Loading branch information
carchi8py committed Aug 5, 2020
1 parent ed673ac commit 0b17eb0
Show file tree
Hide file tree
Showing 18 changed files with 178 additions and 75 deletions.
Binary file modified ansible_collections/netapp/azure/netapp-azure-20.8.0.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion ansible_collections/netapp/ontap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Join our Slack Channel at [Netapp.io](http://netapp.io/slack)
### New Options
- na_ontap_aggregate: support `disk_size_with_unit` option.
- na_ontap_ldap_client: support `ad_domain` and `preferred_ad_server` options.
- na_ontap_rest_info: Support for gather subsets - `cloud_targets_info, cluster_chassis_info, cluster_jobs_info, cluster_metrics_info, cluster_schedules, broadcast_domains_info, cluster_software_history, cluster_software_packages, network_ports_info, ip_interfaces_info, ip_routes_info, ip_service_policies, network_ipspaces_info`.
- na_ontap_rest_info: Support for gather subsets - `cloud_targets_info, cluster_chassis_info, cluster_jobs_info, cluster_metrics_info, cluster_schedules, broadcast_domains_info, cluster_software_history, cluster_software_packages, network_ports_info, ip_interfaces_info, ip_routes_info, ip_service_policies, network_ipspaces_info, san_fc_logins_info, san_fc_wppn-aliases, svm_dns_config_info, svm_ldap_config_info, svm_name_mapping_config_info, svm_nis_config_info, svm_peers_info, svm_peer-permissions_info`.
- na_ontap_rest_info: Support for gather subsets for 9.8+ - `cluster_metrocluster_diagnostics.
- na_ontap_qtree: `force_delete` option with a DEFAULT of `true` so that ZAPI behavior is aligned with REST.
- na_ontap_security_certificates:`ignore_name_if_not_supported` option to not fail if `name` is present since `name` is not supported in ONTAP 9.6 and 9.7.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,6 @@ def volume_unmount(self):
% (to_native(error)),
exception=traceback.format_exc())

def flexcache_delete_async(self):
"""
Delete FlexCache relationship at destination cluster
"""
options = {'volume': self.parameters['volume']}
flexcache_delete = netapp_utils.zapi.NaElement.create_node_with_children(
'flexcache-destroy-async', **options)
try:
result = self.server.invoke_successfully(flexcache_delete, enable_tunneling=True)
except netapp_utils.zapi.NaApiError as error:
self.module.fail_json(msg='Error deleting FlexCache : %s'
% (to_native(error)),
exception=traceback.format_exc())
results = dict()
for key in ('result-status', 'result-jobid'):
if result.get_child_by_name(key):
results[key] = result[key]
return results

def flexcache_delete(self):
"""
Delete FlexCache relationship at destination cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@
"cluster_schedules" or "cluster/schedules",
"cluster_software_history" or "cluster/software/history",
"cluster_software_packages" or "cluster/software/packages",
"network_ports_info" or "network/ethernet/ports",
"disk_info" or "storage/disks",
"ip_interfaces_info" or "network/ip/interfaces",
"ip_routes_info" or "network/ip/routes",
"ip_service_policies" or "network/ip/service-policies",
"network_ipspaces_info" or "network/ipspaces",
"disk_info" or "storage/disks",
"network_ports_info" or "network/ethernet/ports",
"san_fc_logins_info" or "network/fc/logins",
"san_fc_wppn-aliases" or "network/fc/wwpn-aliases",
"svm_dns_config_info" or "name-services/dns",
"svm_ldap_config_info" or "name-services/ldap",
"svm_name_mapping_config_info" or "name-services/name-mappings",
"svm_nis_config_info" or "name-services/nis",
"svm_peers_info" or "svm/peers",
"svm_peer-permissions_info" or "svm/peer-permissions",
"vserver_info" or "svm/svms",
"volume_info" or "storage/volumes",
Can specify a list of values to include a larger subset.
Expand Down Expand Up @@ -270,12 +278,20 @@ def convert_subsets(self):
"cluster_schedules": "cluster/schedules",
"cluster_software_history": "cluster/software/history",
"cluster_software_packages": "cluster/software/packages",
"network_ports_info": "network/ethernet/ports",
"disk_info": "storage/disks",
"ip_interfaces_info": "network/ip/interfaces",
"ip_routes_info": "network/ip/routes",
"ip_service_policies": "network/ip/service-policies",
"network_ipspaces_info": "network/ipspaces",
"disk_info": "storage/disks",
"network_ports_info": "network/ethernet/ports",
"san_fc_logins_info": "network/fc/logins",
"san_fc_wppn-aliases": "network/fc/wwpn-aliases",
"svm_dns_config_info": "name-services/dns",
"svm_ldap_config_info": "name-services/ldap",
"svm_name_mapping_config_info": "name-services/name-mappings",
"svm_nis_config_info": "name-services/nis",
"svm_peers_info": "svm/peers",
"svm_peer-permissions_info": "svm/peer-permissions",
"vserver_info": "svm/svms",
"volume_info": "storage/volumes"
}
Expand All @@ -302,15 +318,6 @@ def apply(self):

# Defining gather_subset and appropriate api_call
get_ontap_subset_info = {
'storage/aggregates': {
'api_call': 'storage/aggregates',
},
'protocols/cifs/services': {
'api_call': 'protocols/cifs/services',
},
'protocols/cifs/shares': {
'api_call': 'protocols/cifs/shares',
},
'cloud/targets': {
'api_call': 'cloud/targets',
},
Expand Down Expand Up @@ -342,9 +349,30 @@ def apply(self):
'cluster/software/packages': {
'api_call': 'cluster/software/packages',
},
'name-services/dns': {
'api_call': 'name-services/dns',
},
'name-services/ldap': {
'api_call': 'name-services/ldap',
},
'name-services/name-mappings': {
'api_call': 'name-services/name-mappings',
},
'name-services/nis': {
'api_call': 'name-services/nis',
},
'network/ethernet/broadcast-domains': {
'api_call': 'network/ethernet/broadcast-domains',
},
'network/ethernet/ports': {
'api_call': 'network/ethernet/ports',
},
'network/fc/logins': {
'api_call': 'network/fc/logins',
},
'network/fc/wwpn-aliases': {
'api_call': 'network/fc/wwpn-aliases',
},
'network/ip/interfaces': {
'api_call': 'network/ip/interfaces',
},
Expand All @@ -357,18 +385,30 @@ def apply(self):
'network/ipspaces': {
'api_call': 'network/ipspaces',
},
'network/ethernet/broadcast-domains': {
'api_call': 'network/ethernet/broadcast-domains',
'storage/aggregates': {
'api_call': 'storage/aggregates',
},
'storage/disks': {
'api_call': 'storage/disks',
},
'storage/volumes': {
'api_call': 'storage/volumes',
},
'svm/peers': {
'api_call': 'svm/peers',
},
'svm/peer-permissions': {
'api_call': 'svm/peer-permissions',
},
'svm/svms': {
'api_call': 'svm/svms',
},
'storage/volumes': {
'api_call': 'storage/volumes',
'protocols/cifs/services': {
'api_call': 'protocols/cifs/services',
},
'protocols/cifs/shares': {
'api_call': 'protocols/cifs/shares',
}
}

if 'all' in self.parameters['gather_subset']:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,7 @@ def snapmirror_update(self):
snapmirror_update = netapp_utils.zapi.NaElement.create_node_with_children(
'snapmirror-update', **options)
try:
result = self.server.invoke_successfully(snapmirror_update,
enable_tunneling=True)
self.server.invoke_successfully(snapmirror_update, enable_tunneling=True)
except netapp_utils.zapi.NaApiError as error:
self.module.fail_json(msg='Error updating SnapMirror : %s'
% (to_native(error)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def test_module_fail_when_required_args_missing(self):

def test_idempotent_modify_dns(self):
data = self.mock_args()
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_dns_mock_object('zapi', 'enable', 'false').apply()
Expand All @@ -160,6 +161,7 @@ def test_idempotent_modify_dns(self):
def test_successfully_modify_dns(self):
data = self.mock_args()
data['domains'] = ['new_test.com']
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_dns_mock_object('zapi', 'enable', 'false').apply()
Expand All @@ -168,6 +170,7 @@ def test_successfully_modify_dns(self):
@patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.ems_log_event')
def test_idempotent_create_dns(self, mock_ems_log_event):
data = self.mock_args()
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_dns_mock_object('zapi').apply()
Expand All @@ -178,6 +181,7 @@ def test_successfully_create_dns(self, mock_ems_log_event):
data = self.mock_args()
print("create dns")
data['domains'] = ['new_test.com']
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_dns_mock_object('zapi', 'create').apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def mock_args(self, rest=False):
'name': self.mock_export_policy['name'],
'hostname': 'test',
'username': 'test_user',
'password': 'test_pass!'
'password': 'test_pass!',
'use_rest': 'never'
}

def get_export_policy_mock_object(self, type='zapi', kind=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ def test_create_flexcache_time_out(self):
if not self.onbox:
my_obj.server = MockONTAPConnection(job_error='time_out')
with patch.object(my_module, 'flexcache_create', wraps=my_obj.flexcache_create) as mock_create:
with pytest.raises(AnsibleFailJson) as exc:
my_obj.apply()
# replace time.sleep with a noop
with patch('time.sleep', lambda a: None):
with pytest.raises(AnsibleFailJson) as exc:
my_obj.apply()
print('Create: ' + repr(exc.value))
msg = 'Error when creating flexcache: job completion exceeded expected timer of: %s seconds' \
% args['time_out']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_ipspace_mock_object(type='zapi', kind=None, status=None):
if kind is None:
ipspace_obj.server = MockONTAPConnection()
else:
ipspace_obj.server = MockONTAPConnection(kind=kind, data=status)
ipspace_obj.server = MockONTAPConnection(kind=kind, parm1=status)
return ipspace_obj

def test_fail_requiredargs_missing(self):
Expand All @@ -127,17 +127,27 @@ def test_fail_requiredargs_missing(self):
my_module()
print('Info: %s' % exc.value.args[0]['msg'])

def test_get_ipspace_iscalled(self):
@patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request')
def test_get_ipspace_iscalled(self, mock_request):
''' test if get_ipspace() is called '''
mock_request.side_effect = [
SRR['is_zapi'],
SRR['end_of_sequence']
]
set_module_args(self.set_default_args())
my_obj = my_module()
my_obj.server = self.server
ipspace = my_obj.get_ipspace()
print('Info: test_get_ipspace: %s' % repr(ipspace))
assert ipspace is None

def test_ipspace_apply_iscalled(self):
@patch('ansible_collections.netapp.ontap.plugins.module_utils.netapp.OntapRestAPI.send_request')
def test_ipspace_apply_iscalled(self, mock_request):
''' test if apply() is called '''
mock_request.side_effect = [
SRR['is_zapi'],
SRR['end_of_sequence']
]
module_args = {'name': 'test_apply_ips'}
module_args.update(self.set_default_args())
set_module_args(module_args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def invoke_successfully(self, xml, enable_tunneling): # pylint: disable=unused-
xml = self.build_job_schedule_cron_info(self.params)
elif self.kind == 'job_multiple':
xml = self.build_job_schedule_multiple_cron_info(self.params)
# TODO: mock invoke_elem for autosupport calls
elif self.kind == 'vserver':
xml = self.build_vserver_info()
self.xml_out = xml
return xml

Expand Down Expand Up @@ -188,7 +185,8 @@ def mock_args(self, rest=False):
'job_minutes': [self.mock_job['minutes']],
'hostname': 'test',
'username': 'test_user',
'password': 'test_pass!'
'password': 'test_pass!',
'use_rest': 'never'
}

def get_job_mock_object(self, kind=None, call_type='zapi'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def test_module_fail_when_required_args_missing(self):
def test_successfully_create_banner(self):
data = self.mock_args()
data['banner'] = 'test banner'
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_login_mock_object('zapi', 'create', data).apply()
Expand All @@ -181,6 +182,7 @@ def test_successfully_create_banner(self):
def test_create_banner_idempotency(self):
data = self.mock_args()
data['banner'] = 'test banner'
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_login_mock_object('zapi', 'create_idempotency', data).apply()
Expand All @@ -189,6 +191,7 @@ def test_create_banner_idempotency(self):
def test_successfully_create_motd(self):
data = self.mock_args()
data['motd_message'] = 'test message'
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_login_mock_object('zapi', 'create', data).apply()
Expand All @@ -197,13 +200,15 @@ def test_successfully_create_motd(self):
def test_create_motd_idempotency(self):
data = self.mock_args()
data['motd_message'] = 'test message'
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleExitJson) as exc:
self.get_login_mock_object('zapi', 'create_idempotency', data).apply()
assert not exc.value.args[0]['changed']

def test_get_banner_error(self):
data = self.mock_args()
data['use_rest'] = 'never'
set_module_args(data)
with pytest.raises(AnsibleFailJson) as exc:
self.get_login_mock_object('zapi', 'error', data).apply()
Expand All @@ -213,6 +218,7 @@ def test_get_banner_error(self):
def test_modify_banner_error(self, get_info):
data = self.mock_args()
data['banner'] = 'modify to new banner'
data['use_rest'] = 'never'
set_module_args(data)
get_info.side_effect = [
{
Expand All @@ -228,6 +234,7 @@ def test_modify_banner_error(self, get_info):
def test_modify_motd_error(self, get_info):
data = self.mock_args()
data['motd_message'] = 'modify to new motd'
data['use_rest'] = 'never'
set_module_args(data)
get_info.side_effect = [
{
Expand Down
Loading

0 comments on commit 0b17eb0

Please sign in to comment.