Revert "New Module: NetApp Account (#59939)"

This reverts commit 6a8dcb8fcb.

Reverting this as it breaks CI for azure (more permissions would be
needed for our account)
pull/61564/head
Toshio Kuratomi 5 years ago
parent f23bb6f7bd
commit 68fa03138c

@ -179,7 +179,6 @@ try:
from msrestazure import AzureConfiguration
from msrest.authentication import Authentication
from azure.mgmt.resource.locks import ManagementLockClient
from azure.mgmt.netapp.azure_net_app_files_management_client import AzureNetAppFilesManagementClient
except ImportError as exc:
Authentication = object
HAS_AZURE_EXC = traceback.format_exc()
@ -332,7 +331,6 @@ class AzureRMModuleBase(object):
self._automation_client = None
self._IoThub_client = None
self._lock_client = None
self._netapp_client = None
self.check_mode = self.module.check_mode
self.api_profile = self.module.params.get('api_profile')
@ -913,15 +911,6 @@ class AzureRMModuleBase(object):
api_version='2018-05-01')
return self._dns_client
@property
def netapp_client(self):
self.log('Getting netapp client')
if not self._netapp_client:
self._netapp_client = self.get_mgmt_svc_client(AzureNetAppFilesManagementClient,
base_url=self._cloud_environment.endpoints.resource_manager,
api_version='2018-05-01')
return self._netapp_client
@property
def dns_models(self):
self.log("Getting dns models...")

@ -1,179 +0,0 @@
#!/usr/bin/python
#
# (c) 2019, NetApp, Inc
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'certified'}
DOCUMENTATION = '''
---
module: azure_rm_netapp_account
short_description: Manage NetApp Azure Files Account
version_added: "2.9"
author: NetApp Ansible Team (@carchi8py) <ng-ansibleteam@netapp.com>
description:
- Create and delete NetApp Azure account.
Provide the Resource group name for the NetApp account to be created.
extends_documentation_fragment:
- netapp.azure_rm_netapp
options:
name:
description:
- The name of the NetApp account.
required: true
type: str
location:
description:
- Resource location.
- Required for create.
type: str
state:
description:
- State C(present) will check that the NetApp account exists with the requested configuration.
- State C(absent) will delete the NetApp account.
default: present
choices:
- absent
- present
type: str
'''
EXAMPLES = '''
- name: Create NetApp Azure Account
azure_rm_netapp_account:
resource_group: myResourceGroup
name: testaccount
location: eastus
- name: Delete NetApp Azure Account
azure_rm_netapp_account:
state: absent
resource_group: myResourceGroup
name: testaccount
location: eastus
'''
RETURN = '''
'''
try:
from msrestazure.azure_exceptions import CloudError
from msrestazure.tools import parse_resource_id
from msrest.polling import LROPoller
except ImportError:
# This is handled in azure_rm_common
pass
from ansible.module_utils.basic import to_native
from ansible.module_utils.azure_rm_common import AzureRMModuleBase
from ansible.module_utils.netapp_module import NetAppModule
from ansible.module_utils.basic import AnsibleModule
import traceback
HAS_AZURE_MGMT_NETAPP = False
try:
from azure.mgmt.netapp.azure_net_app_files_management_client import AzureNetAppFilesManagementClient
from azure.mgmt.netapp.models import NetAppAccount
HAS_AZURE_MGMT_NETAPP = True
except ImportError:
HAS_AZURE_MGMT_NETAPP = False
class AzureRMNetAppAccount(AzureRMModuleBase):
def __init__(self):
self.module_arg_spec = dict(
resource_group=dict(type='str', required=True),
name=dict(type='str', required=True),
location=dict(type='str'),
state=dict(choices=['present', 'absent'], default='present', type='str'),
)
self.module = AnsibleModule(
argument_spec=self.module_arg_spec,
supports_check_mode=True
)
self.na_helper = NetAppModule()
self.parameters = self.na_helper.set_parameters(self.module.params)
# authentication - using CLI
if HAS_AZURE_MGMT_NETAPP is False:
self.module.fail_json(msg="the python Azure-mgmt-NetApp module is required")
super(AzureRMNetAppAccount, self).__init__(derived_arg_spec=self.module_arg_spec,
supports_check_mode=True)
def get_azure_netapp_account(self):
"""
Returns NetApp Account object for an existing account
Return None if account does not exist
"""
try:
account_get = self.netapp_client.accounts.get(self.parameters['resource_group'], self.parameters['name'])
except CloudError: # account does not exist
return None
return account_get
def create_azure_netapp_account(self):
"""
Create an Azure NetApp Account
:return: None
"""
account_body = NetAppAccount(
location=self.parameters['location']
)
try:
self.netapp_client.accounts.create_or_update(body=account_body,
resource_group_name=self.parameters['resource_group'],
account_name=self.parameters['name'])
except CloudError as error:
self.module.fail_json(msg='Error creating Azure NetApp account %s: %s'
% (self.parameters['name'], to_native(error)),
exception=traceback.format_exc())
def delete_azure_netapp_account(self):
"""
Delete an Azure NetApp Account
:return: None
"""
try:
self.netapp_client.accounts.delete(resource_group_name=self.parameters['resource_group'],
account_name=self.parameters['name'])
except CloudError as error:
self.module.fail_json(msg='Error deleting Azure NetApp account %s: %s'
% (self.parameters['name'], to_native(error)),
exception=traceback.format_exc())
def exec_module(self, **kwargs):
current = self.get_azure_netapp_account()
cd_action = self.na_helper.get_cd_action(current, self.parameters)
if self.na_helper.changed:
if self.module.check_mode:
pass
else:
if cd_action == 'create':
self.create_azure_netapp_account()
elif cd_action == 'delete':
self.delete_azure_netapp_account()
self.module.exit_json(changed=self.na_helper.changed)
def main():
AzureRMNetAppAccount()
if __name__ == '__main__':
main()

@ -37,4 +37,3 @@ azure-mgmt-devtestlabs==3.0.0
azure-mgmt-loganalytics==0.2.0
azure-mgmt-automation==0.1.1
azure-mgmt-iothub==0.7.0
azure-mgmt-netapp ; python_version >= '2.7'

@ -1,3 +0,0 @@
cloud/azure
shippable/azure/group3
destructive

@ -1,39 +0,0 @@
- name: Create Azure NetApp account
azure_rm_netapp_account:
resource_group: "{{ resource_group }}"
name: tests-netapp1
location: eastus
register: output
- assert:
that: output.changed
- name: Create Azure NetApp account (Idempotency)
azure_rm_netapp_account:
resource_group: "{{ resource_group }}"
name: tests-netapp1
location: eastus
register: output
- assert:
that: not output.changed
- name: Delete Azure NetApp account
azure_rm_netapp_account:
state: absent
resource_group: "{{ resource_group }}"
name: tests-netapp1
register: output
- assert:
that: output.changed
- name: Delete Azure NetApp account (Idempotency)
azure_rm_netapp_account:
state: absent
resource_group: "{{ resource_group }}"
name: tests-netapp1
register: output
- assert:
that: not output.changed

@ -36,9 +36,6 @@ lxml < 4.3.0 ; python_version < '2.7' # lxml 4.3.0 and later require python 2.7
pyvmomi < 6.0.0 ; python_version < '2.7' # pyvmomi 6.0.0 and later require python 2.7 or later
pyone == 1.1.9 # newer versions do not pass current integration tests
botocore >= 1.10.0 # adds support for the following AWS services: secretsmanager, fms, and acm-pca
azure-common >= 1.1.12 ; python_version >= '2.7'
azure-mgmt-nspkg >= 3.0.0 ; python_version >= '2.7'
azure-nspkg >= 3.0.0 ; python_version >= '2.7'
# freeze pylint and its requirements for consistent test results
astroid == 2.2.5

@ -37,4 +37,3 @@ azure-mgmt-devtestlabs==3.0.0
azure-mgmt-loganalytics==0.2.0
azure-mgmt-automation==0.1.1
azure-mgmt-iothub==0.7.0
azure-mgmt-netapp ; python_version >= '2.7'

Loading…
Cancel
Save