|
|
|
@ -245,7 +245,6 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
self.state = None
|
|
|
|
|
self.sku = None
|
|
|
|
|
self.tags = None
|
|
|
|
|
self._containerregistry_mgmt_client = None
|
|
|
|
|
|
|
|
|
|
self.results = dict(changed=False, state=dict())
|
|
|
|
|
|
|
|
|
@ -315,9 +314,9 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
try:
|
|
|
|
|
if to_do != Actions.NoAction:
|
|
|
|
|
if to_do == Actions.Create:
|
|
|
|
|
name_status = self.containerregistry_mgmt_client.registries.check_name_availability(self.name)
|
|
|
|
|
name_status = self.containerregistry_client.registries.check_name_availability(self.name)
|
|
|
|
|
if name_status.name_available:
|
|
|
|
|
poller = self.containerregistry_mgmt_client.registries.create(
|
|
|
|
|
poller = self.containerregistry_client.registries.create(
|
|
|
|
|
resource_group_name=self.resource_group,
|
|
|
|
|
registry_name=self.name,
|
|
|
|
|
registry=Registry(
|
|
|
|
@ -332,9 +331,9 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
else:
|
|
|
|
|
raise Exception("Invalid registry name. reason: " + name_status.reason + " message: " + name_status.message)
|
|
|
|
|
else:
|
|
|
|
|
registry = self.containerregistry_mgmt_client.registries.get(self.resource_group, self.name)
|
|
|
|
|
registry = self.containerregistry_client.registries.get(self.resource_group, self.name)
|
|
|
|
|
if registry is not None:
|
|
|
|
|
poller = self.containerregistry_mgmt_client.registries.update(
|
|
|
|
|
poller = self.containerregistry_client.registries.update(
|
|
|
|
|
resource_group_name=self.resource_group,
|
|
|
|
|
registry_name=self.name,
|
|
|
|
|
registry_update_parameters=RegistryUpdateParameters(
|
|
|
|
@ -349,7 +348,7 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
raise Exception("Update registry failed as registry '" + self.name + "' doesn't exist.")
|
|
|
|
|
response = self.get_poller_result(poller)
|
|
|
|
|
if self.admin_user_enabled:
|
|
|
|
|
credentials = self.containerregistry_mgmt_client.registries.list_credentials(self.resource_group, self.name)
|
|
|
|
|
credentials = self.containerregistry_client.registries.list_credentials(self.resource_group, self.name)
|
|
|
|
|
else:
|
|
|
|
|
self.log('Cannot perform credential operations as admin user is disabled')
|
|
|
|
|
credentials = None
|
|
|
|
@ -369,7 +368,7 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
'''
|
|
|
|
|
self.log("Deleting the container registry instance {0}".format(self.name))
|
|
|
|
|
try:
|
|
|
|
|
self.containerregistry_mgmt_client.registries.delete(self.resource_group, self.name).wait()
|
|
|
|
|
self.containerregistry_client.registries.delete(self.resource_group, self.name).wait()
|
|
|
|
|
except CloudError as e:
|
|
|
|
|
self.log('Error attempting to delete the container registry instance.')
|
|
|
|
|
self.fail("Error deleting the container registry instance: {0}".format(str(e)))
|
|
|
|
@ -385,7 +384,7 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
self.log("Checking if the container registry instance {0} is present".format(self.name))
|
|
|
|
|
found = False
|
|
|
|
|
try:
|
|
|
|
|
response = self.containerregistry_mgmt_client.registries.get(self.resource_group, self.name)
|
|
|
|
|
response = self.containerregistry_client.registries.get(self.resource_group, self.name)
|
|
|
|
|
found = True
|
|
|
|
|
self.log("Response : {0}".format(response))
|
|
|
|
|
self.log("Container registry instance : {0} found".format(response.name))
|
|
|
|
@ -397,7 +396,7 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
response = None
|
|
|
|
|
if found is True and self.admin_user_enabled is True:
|
|
|
|
|
try:
|
|
|
|
|
credentials = self.containerregistry_mgmt_client.registries.list_credentials(self.resource_group, self.name)
|
|
|
|
|
credentials = self.containerregistry_client.registries.list_credentials(self.resource_group, self.name)
|
|
|
|
|
except CloudError as e:
|
|
|
|
|
self.fail('List registry credentials failed: {0}'.format(str(e)))
|
|
|
|
|
credentials = None
|
|
|
|
@ -407,18 +406,6 @@ class AzureRMContainerRegistry(AzureRMModuleBase):
|
|
|
|
|
return None
|
|
|
|
|
return create_containerregistry_dict(response, credentials)
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def containerregistry_mgmt_client(self):
|
|
|
|
|
self.log('Getting container registry mgmt client')
|
|
|
|
|
if not self._containerregistry_mgmt_client:
|
|
|
|
|
self._containerregistry_mgmt_client = self.get_mgmt_svc_client(
|
|
|
|
|
ContainerRegistryManagementClient,
|
|
|
|
|
base_url=self._cloud_environment.endpoints.resource_manager,
|
|
|
|
|
api_version='2017-10-01'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return self._containerregistry_mgmt_client
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
"""Main execution"""
|
|
|
|
|