def create_account_request_body(self, modify=None): """ Create an Azure NetApp Account Request Body :return: None """ options = dict() location = None for attr in ('location', 'tags', 'active_directories'): value = self.parameters.get(attr) if attr == 'location' and modify is None: location = value continue if value is not None: if modify is None or attr in modify: if attr == 'active_directories': ads = list() for ad_dict in value: if ad_dict.get('dns') is not None: # API expects a string of comma separated elements ad_dict['dns'] = ','.join(ad_dict['dns']) ads.append( ActiveDirectory( **self.na_helper.filter_out_none_entries( ad_dict))) value = ads options[attr] = value if modify is None: if location is None: self.module.fail_json( msg="Error: 'location' is a required parameter") return NetAppAccount(location=location, **options) return NetAppAccountPatch(**options)
def create_account(client, resource_group_name, anf_account_name, location, tags=None): """Creates an Azure NetApp Files Account Function that creates an Azure NetApp Account, which requires building the account body object first. Args: client (NetAppManagementClient): Azure Resource Provider Client designed to interact with ANF resources resource_group_name (string): Name of the resource group where the account will be created location (string): Azure short name of the region where resource will be deployed tags (object): Optional. Key-value pairs to tag the resource, default value is None. E.g. {'cc':'1234','dept':'IT'} Returns: NetAppAccount: Returns the newly created NetAppAccount resource """ account_body = NetAppAccount(location=location, tags=tags) return client.accounts.begin_create_or_update(resource_group_name, anf_account_name, account_body).result()
def create_account(client, resource_group_name, anf_account_name, location, tags=None, active_directories=None): account_body = NetAppAccount(location=location, tags=tags) return client.accounts.create_or_update(account_body, resource_group_name, anf_account_name).result()
def create_account(cmd, client, account_name, resource_group_name, location, tags=None): body = NetAppAccount(location=location, tags=tags) return client.create_or_update(body, resource_group_name, account_name)
def create_account(client, rg, acc_name, location=LOCATION, tags=None, active_directories=None): account_body = NetAppAccount(location=location, tags=tags, active_directories=active_directories) account = client.accounts.begin_create_or_update( rg, acc_name, account_body ).result() return account
def remove_active_directory(cmd, client, account_name, resource_group_name, active_directory): instance = client.get(resource_group_name, account_name) for ad in instance.active_directories: if ad.active_directory_id == active_directory: instance.active_directories.remove(ad) active_directories = instance.active_directories body = NetAppAccount(location=instance.location, tags=instance.tags, active_directories=active_directories) return client.create_or_update(body, resource_group_name, account_name)
def create_account(client, account_name, resource_group_name, location, tags=None, encryption=None): account_encryption = AccountEncryption(key_source=encryption) body = NetAppAccount(location=location, tags=tags, encryption=account_encryption) return client.begin_create_or_update(resource_group_name, account_name, body)
def create_account(cmd, client, account_name, resource_group_name, location, tag=None, active_directories=None): acc_active_directories = build_active_directories(active_directories) body = NetAppAccount(location=location, tags=generate_tags(tag), active_directories=acc_active_directories) return client.create_or_update(body, resource_group_name, account_name)
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())