def Run(self, args): log.warn('Please use instead [gcloud compute instance-groups ' 'managed stop-autoscaling].') client = self.context['autoscaler-client'] messages = self.context['autoscaler_messages_module'] resources = self.context['autoscaler_resources'] try: request = messages.AutoscalerAutoscalersDeleteRequest() for autoscaler in args.names: autoscaler_ref = resources.Parse( autoscaler, collection='autoscaler.autoscalers') request.autoscaler = autoscaler_ref.autoscaler request.project = autoscaler_ref.project request.zone = autoscaler_ref.zone result = client.autoscalers.Delete(request) operation_ref = resources.Create( 'autoscaler.zoneOperations', operation=result.name, autoscaler=request.autoscaler, ) util.WaitForOperation(client, operation_ref, 'Deleting Autoscaler instance') log.DeletedResource(autoscaler_ref) except exceptions.HttpError as error: raise calliope_exceptions.HttpException( util.GetErrorMessage(error)) except ValueError as error: raise calliope_exceptions.HttpException(error)
def Run(self, args): log.warn('Please use instead [gcloud compute instance-groups ' 'managed set-autoscaling].') client = self.context['autoscaler-client'] messages = self.context['autoscaler_messages_module'] resources = self.context['autoscaler_resources'] try: autoscaler_ref = resources.Parse( args.name, collection='autoscaler.autoscalers') request = messages.AutoscalerAutoscalersUpdateRequest() request.project = autoscaler_ref.project request.zone = autoscaler_ref.zone request.autoscaler = autoscaler_ref.autoscaler request.autoscalerResource = util.PrepareAutoscaler( args, messages, resources) request.autoscalerResource.name = autoscaler_ref.autoscaler result = client.autoscalers.Update(request) if result.error: raise exceptions.Error(util.GetErrorMessage(result.error)) operation_ref = resources.Create( 'autoscaler.zoneOperations', operation=result.name, autoscaler=request.autoscaler, ) util.WaitForOperation(client, operation_ref, 'Updating Autoscaler instance') log.status.write('Updated [{0}].\n'.format(args.name)) except exceptions.HttpError as error: raise calliope_exceptions.HttpException(util.GetErrorMessage(error)) except ValueError as error: raise calliope_exceptions.HttpException(error)
def Run(self, args): log.warn('Please use instead [gcloud compute instance-groups ' 'managed set-autoscaling].') messages = self.context['autoscaler_messages_module'] client = self.context['autoscaler-client'] resources = self.context['autoscaler_resources'] autoscaler_ref = resources.Parse( args.name, collection='autoscaler.autoscalers') try: request = messages.AutoscalerAutoscalersInsertRequest() request.project = autoscaler_ref.project request.zone = autoscaler_ref.zone request.autoscaler = util.PrepareAutoscaler(args, messages, resources) request.autoscaler.name = autoscaler_ref.autoscaler result = client.autoscalers.Insert(request) operation_ref = resources.Create( 'autoscaler.zoneOperations', operation=result.name, autoscaler=request.autoscaler, ) if args.async: return client.zoneOperations.Get(operation_ref.Request()) util.WaitForOperation(client, operation_ref, 'Creating Autoscaler instance') log.CreatedResource(autoscaler_ref) return client.autoscalers.Get(autoscaler_ref.Request()) except exceptions.HttpError as error: raise calliope_exceptions.HttpException(util.GetErrorMessage(error)) except ValueError as error: raise calliope_exceptions.HttpException(error)