Пример #1
0
def AddFlagsToSpecificSkuGroup(group):
  """Adds flags needed for a specific sku zonal allocation."""
  args = [
      reservation_flags.GetRequireSpecificAllocation(),
      reservation_flags.GetVmCountFlag(required=False),
      reservation_flags.GetMinCpuPlatform(),
      reservation_flags.GetMachineType(required=False),
      reservation_flags.GetLocalSsdFlag(),
      reservation_flags.GetAcceleratorFlag(),
  ]

  for arg in args:
    arg.AddToParser(group)
def AddCreateFlags(
    parser,
    support_location_hint=False,
    support_share_setting=False,
    support_fleet=False,
):
    """Adds all flags needed for the create command."""
    GetNamePrefixFlag().AddToParser(parser)
    GetTotalCountFlag().AddToParser(parser)
    reservation_flags.GetDescriptionFlag().AddToParser(parser)

    group = base.ArgumentGroup(
        'Manage the specific SKU reservation properties.', required=True)
    group.AddArgument(reservation_flags.GetMachineType())
    group.AddArgument(reservation_flags.GetMinCpuPlatform())
    group.AddArgument(reservation_flags.GetLocalSsdFlag())
    group.AddArgument(reservation_flags.GetAcceleratorFlag())
    if support_location_hint:
        group.AddArgument(reservation_flags.GetLocationHint())
    if support_fleet:
        group.AddArgument(instance_flags.AddMaintenanceFreezeDuration())
        group.AddArgument(instance_flags.AddMaintenanceInterval())
    group.AddToParser(parser)

    time_window_group = parser.add_group(
        help=
        'Manage the time specific properties for requesting future capacity',
        required=True)
    time_window_group.add_argument('--start-time',
                                   required=True,
                                   help=GetStartTimeHelpText())
    end_time_window_group = time_window_group.add_mutually_exclusive_group(
        required=True)
    end_time_window_group.add_argument('--end-time', help=GetEndTimeHelpText())
    end_time_window_group.add_argument('--duration',
                                       type=int,
                                       help=GetDurationHelpText())

    if support_share_setting:
        share_group = base.ArgumentGroup(
            'Manage the properties of a shared reservation.', required=False)
        share_group.AddArgument(GetSharedSettingFlag())
        share_group.AddArgument(GetShareWithFlag())
        share_group.AddToParser(parser)