Esempio n. 1
0
def AddCreateFlags(parser,
                   support_location_hint=False,
                   support_fleet=False,
                   support_share_setting=False):
    """Adds all flags needed for the create command."""
    GetDescriptionFlag().AddToParser(parser)

    group = base.ArgumentGroup(
        'Manage the specific SKU reservation properties to create',
        required=True)

    group.AddArgument(GetRequireSpecificAllocation())
    group.AddArgument(GetVmCountFlag())
    group.AddArgument(GetMinCpuPlatform())
    group.AddArgument(GetMachineType())
    group.AddArgument(GetLocalSsdFlag())
    group.AddArgument(GetAcceleratorFlag())
    if support_location_hint:
        group.AddArgument(GetLocationHint())
    if support_fleet:
        group.AddArgument(instance_flags.AddMaintenanceFreezeDuration())
        group.AddArgument(instance_flags.AddMaintenanceInterval())
    group.AddToParser(parser)

    if support_share_setting:
        share_group = base.ArgumentGroup(
            'Manage the properties of a shared reservation to create',
            required=False)
        share_group.AddArgument(GetSharedSettingFlag())
        share_group.AddArgument(GetShareWithFlag())
        share_group.AddToParser(parser)
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)