Beispiel #1
0
 def _CreateNewInstanceReference(holder, igm_ref, instance_name):
     """Creates reference to instance in instance group (zonal or regional)."""
     if igm_ref.Collection() == 'compute.instanceGroupManagers':
         instance_ref = holder.resources.Parse(
             instance_name,
             params={
                 'project': igm_ref.project,
                 'zone': igm_ref.zone,
             },
             collection='compute.instances')
     elif igm_ref.Collection() == 'compute.regionInstanceGroupManagers':
         instance_ref = holder.resources.Parse(
             instance_name,
             params={
                 'project': igm_ref.project,
                 'zone': igm_ref.region + '-a',
             },
             collection='compute.instances')
     else:
         raise ValueError('Unknown reference type {0}'.format(
             igm_ref.Collection()))
     if not instance_ref:
         raise managed_instance_groups_utils.ResourceCannotBeResolvedException(
             'Instance name {0} cannot be resolved.'.format(instance_name))
     return instance_ref
Beispiel #2
0
 def _CreateInstanceReference(holder, igm_ref, instance_name):
     """Creates reference to instance in instance group (zonal or regional)."""
     if instance_name.startswith('https://') or instance_name.startswith(
             'http://'):
         return holder.resources.ParseURL(instance_name)
     instance_references = (
         managed_instance_groups_utils.CreateInstanceReferences)(
             holder=holder, igm_ref=igm_ref, instance_names=[instance_name])
     if not instance_references:
         raise managed_instance_groups_utils.ResourceCannotBeResolvedException(
             'Instance name {0} cannot be resolved'.format(instance_name))
     return instance_references[0]