def __delete_endpoint_in_azure(self, context): self.log.debug('private_endpoints: %s' % context.private_endpoints) deployment_name = self.azure_adapter.get_deployment_name(context.azure_key_id, context.cloud_service_name, context.deployment_slot) network_config = self.azure_adapter.get_virtual_machine_network_config(context.azure_key_id, context.cloud_service_name, deployment_name, context.virtual_machine_name) new_network_config = delete_endpoint_from_network_config(network_config, context.private_endpoints) if new_network_config is None: return False
def release_public_endpoints(self, context): """ Release public endpoints of cloud service according to private endpoints of virtual machine Return False if failed :param context : contains azure_key_id cloud_service_name: deployment_slot: virtual_machine_name: private_endpoints: a list of int or str :return: """ self.log.debug('private_endpoints: %s' % context.private_endpoints) deployment_name = self.azure_adapter.get_deployment_name(context.azure_key_id, context.cloud_service_name, context.deployment_slot) network_config = self.azure_adapter.get_virtual_machine_network_config(context.azure_key_id, context.cloud_service_name, deployment_name, context.virtual_machine_name) new_network_config = delete_endpoint_from_network_config(network_config, context.private_endpoints) if new_network_config is None: return False try: result = self.azure_adapter.update_virtual_machine_network_config(context.azure_key_id, context.cloud_service_name, deployment_name, context.virtual_machine_name, new_network_config) except Exception as e: self.log.error(e) return False if not self.azure_adapter.wait_for_async(context.azure_key_id, result.request_id, self.TICK, self.LOOP): self.log.error('wait for async fail') return False if not self.azure_adapter.wait_for_virtual_machine(context.azure_key_id, context.cloud_service_name, deployment_name, context.virtual_machine_name, self.TICK, self.LOOP, AVMStatus.READY_ROLE): self.log.error('%s [%s] not ready' % (AZURE_RESOURCE_TYPE.VIRTUAL_MACHINE, context.virtual_machine_name)) return False return True