def add_active_directory(cmd, instance, account_name, resource_group_name, username, password, domain, dns, smb_server_name, organizational_unit=None, kdc_ip=None, ad_name=None, server_root_ca_cert=None, backup_operators=None): active_directories = [] active_directory = ActiveDirectory( username=username, password=password, domain=domain, dns=dns, smb_server_name=smb_server_name, organizational_unit=organizational_unit, kdc_ip=kdc_ip, ad_name=ad_name, backup_operators=backup_operators, server_root_ca_certificate=server_root_ca_cert) active_directories.append(active_directory) body = NetAppAccountPatch(active_directories=active_directories) _update_mapper(instance, body, ['active_directories']) return body
def add_active_directory(cmd, instance, account_name, resource_group_name, username, password, domain, dns, smb_server_name, organizational_unit=None): active_directories = [] active_directory = ActiveDirectory(username=username, password=password, domain=domain, dns=dns, smb_server_name=smb_server_name, organizational_unit=organizational_unit) active_directories.append(active_directory) body = NetAppAccountPatch(active_directories=active_directories) _update_mapper(instance, body, ['active_directories']) return body
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 patch_account(instance, account_name, resource_group_name, tags=None, encryption=None): account_encryption = AccountEncryption(key_source=encryption) body = NetAppAccountPatch(tags=tags, encryption=account_encryption) _update_mapper(instance, body, ['tags']) return body
def test_patch_account(self): create_account(self.client, TEST_RG, TEST_ACC_1) tag = {'Tag1': 'Value2'} netapp_account_patch = NetAppAccountPatch(tags=tag) account = self.client.accounts.begin_update(TEST_RG, TEST_ACC_1, netapp_account_patch).result() self.assertTrue(account.tags['Tag1'] == 'Value2') delete_account(self.client, TEST_RG, TEST_ACC_1)
def update_active_directory(instance, account_name, resource_group_name, active_directory_id, username, password, domain, dns, smb_server_name, organizational_unit=None, kdc_ip=None, ad_name=None, server_root_ca_cert=None, backup_operators=None, aes_encryption=None, ldap_signing=None, security_operators=None, ldap_over_tls=None, allow_local_ldap_users=None, administrators=None, encrypt_dc_conn=None, tags=None): ad_list = instance.active_directories active_directory = ActiveDirectory( active_directory_id=active_directory_id, username=username, password=password, domain=domain, dns=dns, smb_server_name=smb_server_name, organizational_unit=organizational_unit, kdc_ip=kdc_ip, ad_name=ad_name, backup_operators=backup_operators, server_root_ca_certificate=server_root_ca_cert, aes_encryption=aes_encryption, ldap_signing=ldap_signing, security_operators=security_operators, ldap_over_tls=ldap_over_tls, allow_local_nfs_users_with_ldap=allow_local_ldap_users, administrators=administrators, encrypt_dc_connections=encrypt_dc_conn) for ad in ad_list: if ad.active_directory_id == active_directory_id: instance.active_directories.remove(ad) instance.active_directories.append(active_directory) body = NetAppAccountPatch(active_directories=ad_list) _update_mapper(instance, body, ['active_directories']) return body
def patch_account(cmd, instance, account_name, resource_group_name, location, tag=None, active_directories=None): # parameters for active directory here will add to the existing ADs but cannot remove them # current limitation however is 1 AD/subscription acc_active_directories = build_active_directories(active_directories) body = NetAppAccountPatch(location=location, tags=generate_tags(tag), active_directories=acc_active_directories) _update_mapper(instance, body, ['location', 'active_directories', 'tags']) return body
def update_account(cmd, client, account_name, resource_group_name, location, tag=None, active_directories=None): # Note: this set command is required in addition to the update # The RP implementation is such that patch of active directories provides an addition type amendment, i.e. # absence of an AD does not remove the ADs already present. To perform this a set command is required that # asserts exactly the content provided, replacing whatever is already present including removing it if none # is present acc_active_directories = build_active_directories(active_directories) body = NetAppAccountPatch(location=location, tags=generate_tags(tag), active_directories=acc_active_directories) return client.create_or_update(body, resource_group_name, account_name)
def add_active_directory(instance, account_name, resource_group_name, username, password, domain, dns, smb_server_name, organizational_unit=None, kdc_ip=None, ad_name=None, server_root_ca_cert=None, backup_operators=None, aes_encryption=None, ldap_signing=None, security_operators=None, ldap_over_tls=None, allow_local_ldap_users=None, tags=None): active_directories = [] active_directory = ActiveDirectory( username=username, password=password, domain=domain, dns=dns, smb_server_name=smb_server_name, organizational_unit=organizational_unit, kdc_ip=kdc_ip, ad_name=ad_name, backup_operators=backup_operators, server_root_ca_certificate=server_root_ca_cert, aes_encryption=aes_encryption, ldap_signing=ldap_signing, security_operators=security_operators, ldap_over_tls=ldap_over_tls, allow_local_nfs_users_with_ldap=allow_local_ldap_users) active_directories.append(active_directory) body = NetAppAccountPatch(active_directories=active_directories) _update_mapper(instance, body, ['active_directories']) return body
def patch_account(cmd, instance, account_name, resource_group_name, tags=None): body = NetAppAccountPatch(tags=tags) _update_mapper(instance, body, ['tags']) return body