def _CreateInstanceGroupManager(self, args, group_ref, template_ref, client, holder): """Create parts of Instance Group Manager shared for the track.""" instance_groups_flags.ValidateManagedInstanceGroupScopeArgs( args, holder.resources) instance_groups_flags.ValidateManagedInstanceGroupStatefulProperties( args) health_check = managed_instance_groups_utils.GetHealthCheckUri( holder.resources, args, self.HEALTH_CHECK_ARG) return client.messages.InstanceGroupManager( name=group_ref.Name(), description=args.description, instanceTemplate=template_ref.SelfLink(), baseInstanceName=self._GetInstanceGroupManagerBaseInstanceName( args.base_instance_name, group_ref), targetPools=self._GetInstanceGroupManagerTargetPools( args.target_pool, group_ref, holder), targetSize=int(args.size), autoHealingPolicies=( managed_instance_groups_utils.CreateAutohealingPolicies( client.messages, health_check, args.initial_delay)), distributionPolicy=self._CreateDistributionPolicy( args.zones, holder.resources, client.messages), statefulPolicy=self._GetStatefulPolicy(args, client), )
def _CreateInstanceGroupManager(self, args, group_ref, template_ref, client, holder): """Create parts of Instance Group Manager shared for the track.""" instance_groups_flags.ValidateManagedInstanceGroupScopeArgs( args, holder.resources) health_check = managed_instance_groups_utils.GetHealthCheckUri( holder.resources, args) auto_healing_policies = ( managed_instance_groups_utils.CreateAutohealingPolicies( client.messages, health_check, args.initial_delay)) managed_instance_groups_utils.ValidateAutohealingPolicies( auto_healing_policies) instance_groups_flags.ValidateMigInstanceRedistributionTypeFlag( args.GetValue('instance_redistribution_type'), group_ref) update_policy = (managed_instance_groups_utils. ApplyInstanceRedistributionTypeToUpdatePolicy)( client, args.GetValue('instance_redistribution_type'), None) instance_group_manager = client.messages.InstanceGroupManager( name=group_ref.Name(), description=args.description, instanceTemplate=template_ref.SelfLink(), baseInstanceName=self._GetInstanceGroupManagerBaseInstanceName( args.base_instance_name, group_ref), targetPools=self._GetInstanceGroupManagerTargetPools( args.target_pool, group_ref, holder), targetSize=int(args.size), autoHealingPolicies=auto_healing_policies, distributionPolicy=self._CreateDistributionPolicy( args.zones, holder.resources, client.messages), updatePolicy=update_policy, ) # Handle stateful args instance_groups_flags.ValidateManagedInstanceGroupStatefulProperties( args) if args.stateful_disk: instance_group_manager.statefulPolicy = ( self._CreateStatefulPolicy(args, client)) # Validate updatePolicy + statefulPolicy combination ValidateAndFixUpdatePolicyAgainstStateful( instance_group_manager.updatePolicy, group_ref, instance_group_manager.statefulPolicy, client) return instance_group_manager