def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client igm_ref = (instance_groups_flags.MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG .ResolveAsResource)( args, holder.resources, default_scope=compute_scope.ScopeEnum.ZONE, scope_lister=flags.GetDefaultScopeLister(client)) update_instances_utils.ValidateIgmReference(igm_ref) if igm_ref.Collection() == 'compute.instanceGroupManagers': minimal_action = update_instances_utils.ParseInstanceActionFlag( '--minimal-action', args.minimal_action or 'none', client.messages.InstanceGroupManagersApplyUpdatesRequest .MinimalActionValueValuesEnum) most_disruptive_allowed_action = ( update_instances_utils.ParseInstanceActionFlag)( '--most-disruptive-allowed-action', args.most_disruptive_allowed_action or 'replace', client.messages.InstanceGroupManagersApplyUpdatesRequest .MostDisruptiveAllowedActionValueValuesEnum) instances_holder_field = 'instanceGroupManagersApplyUpdatesRequest' request = self._CreateZonalApplyUpdatesRequest( igm_ref, minimal_action, most_disruptive_allowed_action, client) elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers': minimal_action = update_instances_utils.ParseInstanceActionFlag( '--minimal-action', args.minimal_action or 'none', client.messages.RegionInstanceGroupManagersApplyUpdatesRequest .MinimalActionValueValuesEnum) most_disruptive_allowed_action = ( update_instances_utils.ParseInstanceActionFlag)( '--most-disruptive-allowed-action', args.most_disruptive_allowed_action or 'replace', client.messages.RegionInstanceGroupManagersApplyUpdatesRequest .MostDisruptiveAllowedActionValueValuesEnum) instances_holder_field = 'regionInstanceGroupManagersApplyUpdatesRequest' request = self._CreateRegionalApplyUpdatesRequest( igm_ref, minimal_action, most_disruptive_allowed_action, client) else: raise ValueError('Unknown reference type {0}'.format( igm_ref.Collection())) if args.all_instances: return instance_groups_utils.SendAllInstancesRequest( api_holder=holder, method_name='ApplyUpdatesToInstances', request_template=request, all_instances_holder_field=instances_holder_field, igm_ref=igm_ref) else: return instance_groups_utils.SendInstancesRequestsAndPostProcessOutputs( api_holder=holder, method_name='ApplyUpdatesToInstances', request_template=request, instances_holder_field=instances_holder_field, igm_ref=igm_ref, instances=args.instances)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client igm_ref = (instance_groups_flags.MULTISCOPE_INSTANCE_GROUP_MANAGER_ARG. ResolveAsResource)( args, holder.resources, default_scope=compute_scope.ScopeEnum.ZONE, scope_lister=flags.GetDefaultScopeLister(client)) update_instances_utils.ValidateIgmReference(igm_ref) minimal_action = update_instances_utils.ParseInstanceActionFlag( '--minimal-action', args.minimal_action or 'none', client.messages) most_disruptive_allowed_action = ( update_instances_utils.ParseInstanceActionFlag)( '--most-disruptive-allowed-action', args.most_disruptive_allowed_action or 'replace', client.messages) instances = instance_groups_utils.CreateInstanceReferences( holder.resources, client, igm_ref, args.instances) if igm_ref.Collection() == 'compute.instanceGroupManagers': field_name, service, requests = self._CreateZonalApplyUpdatesRequest( igm_ref, instances, minimal_action, most_disruptive_allowed_action, client) elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers': field_name, service, requests = self._CreateRegionalApplyUpdatesRequest( igm_ref, instances, minimal_action, most_disruptive_allowed_action, client) requests = instance_groups_utils.GenerateRequestTuples( service, 'ApplyUpdatesToInstances', requests) operations = instance_groups_utils.MakeRequestsList( client, requests, field_name) return operations