Esempio n. 1
0
def AddReservationArgGroup(parser):
    """Adds all flags needed for reservations creation."""
    reservations_manage_group = parser.add_group(
        'Manage the reservations to be created with the commitment.',
        mutex=True)

    reservations_manage_group.add_argument(
        '--reservations-from-file',
        type=arg_parsers.BufferedFileInput(),
        help='The path to a YAML file of multiple reservations\' configuration.'
    )

    single_reservation_group = reservations_manage_group.add_argument_group(
        help='Manage the reservation to be created with the commitment.')
    resource_args.GetReservationResourceArg(
        positional=False).AddArgument(single_reservation_group)
    single_reservation_group.add_argument(
        '--reservation-type',
        hidden=True,
        choices=['specific'],
        default='specific',
        help='The type of the reservation to be created.')

    specific_sku_reservation_group = single_reservation_group.add_argument_group(
        help='Manage the specific SKU reservation properties to create.')
    AddFlagsToSpecificSkuGroup(specific_sku_reservation_group)
Esempio n. 2
0
def _MakeSingleReservation(args, messages, holder):
    """Makes one Allocation message object."""
    reservation_ref = resource_args.GetReservationResourceArg(
        positional=False).ResolveAsResource(
            args,
            holder.resources,
            scope_lister=compute_flags.GetDefaultScopeLister(holder.client))
    return util.MakeAllocationMessageFromArgs(messages, args, reservation_ref)
Esempio n. 3
0
  def Run(self, args):
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    resources = holder.resources
    reservation_ref = resource_args.GetReservationResourceArg(
    ).ResolveAsResource(
        args,
        resources,
        scope_lister=compute_flags.GetDefaultScopeLister(holder.client))

    messages = holder.client.messages
    project = reservation_ref.project
    create_request = self._MakeCreateRequest(args, messages, project,
                                             reservation_ref)

    service = holder.client.apitools_client.reservations
    return holder.client.MakeRequests([(service, 'Insert', create_request)])
Esempio n. 4
0
 def Args(parser):
   resource_args.GetReservationResourceArg().AddArgument(
       parser, operation_type='create')
   flags.AddCreateFlags(parser)