Skip to content

Commit

Permalink
Sync bitbucket and GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
carchi8py committed Aug 23, 2021
1 parent 0c41487 commit 1f043e8
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 87 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ This collection follows the [Ansible project's Code of Conduct](https://docs.ans
# Release Notes


## 21.9.0

### New Options
- azure_rm_netapp_volume - `feature_flags` to selectively enable/disable a feature.

### Bug Fixes
- azure_rm_netapp_volume - 'Change Ownership' is not permitted when creating NFSv4.1 volume with latest azure-mgmt-netapp package (4.0.0).

## 21.8.1

### Bug Fixes
Expand Down
4 changes: 4 additions & 0 deletions changelogs/fragments/DEVOPS-4246.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
minor_changes:
- azure_rm_netapp_volume - new option ``feature_flags`` to selectively enable/disable a feature.
bugfixes:
- azure_rm_netapp_volume - 'Change Ownership' is not permitted when creating NFSv4.1 volume with latest azure-mgmt-netapp package (4.0.0).
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: "netapp"
name: "azure"
version: "21.8.1"
version: "21.9.0"
authors:
- "NetApp Ansible Team <[email protected]>"
license_file: COPYING
Expand Down
42 changes: 40 additions & 2 deletions plugins/module_utils/azure_rm_netapp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

HAS_AZURE_COLLECTION = True
NEW_STYLE = None
COLLECTION_VERSION = "21.8.1"
IMPORT_ERRORS = list()
COLLECTION_VERSION = "21.9.0"
IMPORT_ERRORS = []
SDK_VERSION = "0.0.0"

if 'pytest' in sys.modules:
from ansible_collections.netapp.azure.plugins.module_utils.netapp_module import AzureRMModuleBaseMock as AzureRMModuleBase
Expand Down Expand Up @@ -45,12 +46,18 @@
except ImportError as exc:
IMPORT_ERRORS.append(str(exc))

try:
from azure.mgmt.netapp import VERSION as SDK_VERSION
except ImportError as exc:
IMPORT_ERRORS.append(str(exc))


class AzureRMNetAppModuleBase(AzureRMModuleBase):
''' Wrapper around AzureRMModuleBase base class '''
def __init__(self, derived_arg_spec, required_if=None, supports_check_mode=False, supports_tags=True):
self._netapp_client = None
self._new_style = NEW_STYLE
self._sdk_version = SDK_VERSION
super(AzureRMNetAppModuleBase, self).__init__(derived_arg_spec=derived_arg_spec,
required_if=required_if,
supports_check_mode=supports_check_mode,
Expand Down Expand Up @@ -91,6 +98,10 @@ def netapp_client(self):
def new_style(self):
return self._new_style

@property
def sdk_version(self):
return self._sdk_version

def get_method(self, category, name):
try:
methods = getattr(self.netapp_client, category)
Expand All @@ -116,3 +127,30 @@ def fail_when_import_errors(self, import_errors, has_azure_mgmt_netapp=True):
self.module.fail_json(msg=msg)
msg += str(import_errors)
raise ImportError(msg)

def has_feature(self, feature_name):
feature = self.get_feature(feature_name)
if isinstance(feature, bool):
return feature
self.module.fail_json(msg="Error: expected bool type for feature flag: %s" % feature_name)

def get_feature(self, feature_name):
''' if the user has configured the feature, use it
otherwise, use our default
'''
default_flags = dict(
# TODO: review need for these
# trace_apis=False, # if true, append REST requests/responses to /tmp/azure_apis.log
# check_required_params_for_none=True,
# deprecation_warning=True,
# show_modified=True,
#
# preview features in ANF
ignore_change_ownership_mode=True
)

if self.parameters.get('feature_flags') is not None and feature_name in self.parameters['feature_flags']:
return self.parameters['feature_flags'][feature_name]
if feature_name in default_flags:
return default_flags[feature_name]
self.module.fail_json(msg="Internal error: unexpected feature flag: %s" % feature_name)
31 changes: 16 additions & 15 deletions plugins/module_utils/netapp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def __init__(self, derived_arg_spec, required_if=None, supports_check_mode=False
# remove values with a default of None (not required)
self.module_arg_spec = dict([item for item in self.module_arg_spec.items() if item[0] in self.parameters])

def update_tags(self, tags):
self.module.log('update_tags called with:', tags)
return None, None


def cmp(obj1, obj2):
"""
Expand Down Expand Up @@ -83,17 +87,17 @@ class NetAppModule():
'''

def __init__(self):
self.log = list()
self.log = []
self.changed = False
self.parameters = {'name': 'not intialized'}
self.zapi_string_keys = dict()
self.zapi_bool_keys = dict()
self.zapi_list_keys = dict()
self.zapi_int_keys = dict()
self.zapi_required = dict()
self.zapi_list_keys = {}
self.zapi_int_keys = {}
self.zapi_required = {}

def set_parameters(self, ansible_params):
self.parameters = dict()
self.parameters = {}
for param in ansible_params:
if ansible_params[param] is not None:
self.parameters[param] = ansible_params[param]
Expand All @@ -109,11 +113,7 @@ def get_cd_action(self, current, desired):
is_present = 'present'
action = cd_action(current=is_present, desired = self.desired.state())
'''
if 'state' in desired:
desired_state = desired['state']
else:
desired_state = 'present'

desired_state = desired['state'] if 'state' in desired else 'present'
if current is None and desired_state == 'absent':
return None
if current is not None and desired_state == 'present':
Expand All @@ -125,7 +125,7 @@ def get_cd_action(self, current, desired):
return 'create'

def compare_and_update_values(self, current, desired, keys_to_compare):
updated_values = dict()
updated_values = {}
is_changed = False
for key in keys_to_compare:
if key in current:
Expand Down Expand Up @@ -185,7 +185,7 @@ def get_modified_attributes(self, current, desired, get_list_diff=False):
aggregate name)
'''
# if the object does not exist, we can't modify it
modified = dict()
modified = {}
if current is None:
return modified

Expand Down Expand Up @@ -224,7 +224,7 @@ def is_rename_action(self, source, target):
# idempotency (or) new_name_is_already_in_use
# alternatively we could delete B and rename A to B
return False
if source is None and target is not None:
if source is None:
# do nothing, maybe the rename was already done
return False
# source is not None and target is None:
Expand All @@ -238,7 +238,7 @@ def filter_out_none_entries(self, list_or_dict):
"""

if isinstance(list_or_dict, dict):
result = dict()
result = {}
for key, value in list_or_dict.items():
if isinstance(value, (list, dict)):
sub = self.filter_out_none_entries(value)
Expand All @@ -251,7 +251,7 @@ def filter_out_none_entries(self, list_or_dict):
return result

if isinstance(list_or_dict, list):
alist = list()
alist = []
for item in list_or_dict:
if isinstance(item, (list, dict)):
sub = self.filter_out_none_entries(item)
Expand All @@ -267,4 +267,5 @@ def filter_out_none_entries(self, list_or_dict):

@staticmethod
def get_not_none_values_from_dict(parameters, keys):
# python 2.6 does not support dict comprehension using k: v
return dict((key, value) for key, value in parameters.items() if key in keys and value is not None)
Loading

0 comments on commit 1f043e8

Please sign in to comment.