def Args(parser):
     disks_flags.MakeDiskArg(plural=False).AddArgument(
         parser, operation_type='add resource policies to')
     flags.AddResourcePoliciesArgs(parser,
                                   'added to',
                                   'disk',
                                   required=True)
Exemplo n.º 2
0
 def Args(parser):
   Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
   _CommonArgs(parser)
   image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.GA)
   _AddReplicaZonesArg(parser)
   kms_resource_args.AddKmsKeyResourceArg(
       parser, 'disk', region_fallthrough=True)
Exemplo n.º 3
0
 def Args(parser):
     disks_flags.MakeDiskArg(plural=False).AddArgument(
         parser, operation_type='remove resource policies from')
     flags.AddResourcePoliciesArgs(parser,
                                   'removed from',
                                   'disk',
                                   required=True)
    def Run(self, args):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client
        messages = client.messages

        disk_ref = disks_flags.MakeDiskArg(plural=False).ResolveAsResource(
            args, holder.resources)

        resource_policies = []
        for policy in args.resource_policies:
            resource_policy_ref = util.ParseResourcePolicyWithZone(
                holder.resources,
                policy,
                project=disk_ref.project,
                zone=disk_ref.zone)
            resource_policies.append(resource_policy_ref.SelfLink())

        add_request = messages.ComputeDisksAddResourcePoliciesRequest(
            disk=disk_ref.Name(),
            project=disk_ref.project,
            zone=disk_ref.zone,
            disksAddResourcePoliciesRequest=messages.
            DisksAddResourcePoliciesRequest(
                resourcePolicies=resource_policies))

        return client.MakeRequests([(client.apitools_client.disks,
                                     'AddResourcePolicies', add_request)])
Exemplo n.º 5
0
 def Args(cls, parser):
     # Regional disk is in Alpha only.
     if cls.ReleaseTrack() == base.ReleaseTrack.ALPHA:
         cls.DISK_ARG = disks_flags.MakeDiskArgZonalOrRegional(plural=False)
     else:
         cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
     cls.DISK_ARG.AddArgument(parser, operation_type='update')
     labels_util.AddUpdateLabelsFlags(parser)
Exemplo n.º 6
0
 def Args(cls, parser):
   messages = cls._GetApiHolder(no_http=True).client.messages
   Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
   _CommonArgs(parser)
   image_utils.AddGuestOsFeaturesArg(parser, messages)
   _AddReplicaZonesArg(parser)
   kms_resource_args.AddKmsKeyResourceArg(
       parser, 'disk', region_fallthrough=True)
Exemplo n.º 7
0
 def Args(cls, parser):
     # Regional disk is in Alpha only.
     if cls.ReleaseTrack() == base.ReleaseTrack.ALPHA:
         cls.DISK_ARG = disks_flags.MakeDiskArgZonalOrRegional(plural=False)
     else:
         cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
     cls.DISK_ARG.AddArgument(parser)
     labels_flags.AddArgsForAddLabels(parser)
Exemplo n.º 8
0
    def Args(parser):
        Create.disks_arg = disks_flags.MakeDiskArg(plural=True)

        _CommonArgs(parser, include_physical_block_size_support=True)
        image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.BETA)
        _AddReplicaZonesArg(parser)
        kms_resource_args.AddKmsKeyResourceArg(parser,
                                               'disk',
                                               region_fallthrough=True)
Exemplo n.º 9
0
    def Args(parser):
        Move.disk_arg = disks_flags.MakeDiskArg(plural=False)
        Move.disk_arg.AddArgument(parser)

        parser.add_argument('--destination-zone',
                            help='The zone to move the disk to.',
                            completer=completers.ZonesCompleter,
                            required=True)

        base.ASYNC_FLAG.AddToParser(parser)
Exemplo n.º 10
0
 def Args(cls, parser):
     messages = cls._GetApiHolder(no_http=True).client.messages
     Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
     _CommonArgs(parser,
                 include_physical_block_size_support=True,
                 vss_erase_enabled=True)
     image_utils.AddGuestOsFeaturesArg(parser, messages)
     _AddReplicaZonesArg(parser)
     kms_resource_args.AddKmsKeyResourceArg(parser,
                                            'disk',
                                            region_fallthrough=True)
Exemplo n.º 11
0
    def Args(parser):
        Create.disks_arg = disks_flags.MakeDiskArg(plural=True)

        _CommonArgs(parser,
                    disks_flags.SOURCE_SNAPSHOT_ARG,
                    include_physical_block_size_support=True)
        image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.ALPHA)
        _AddReplicaZonesArg(parser)
        resource_flags.AddResourcePoliciesArgs(parser, 'added to', 'disk')
        kms_resource_args.AddKmsKeyResourceArg(parser,
                                               'disk',
                                               region_fallthrough=True)
Exemplo n.º 12
0
 def Args(cls, parser):
     messages = cls._GetApiHolder(no_http=True).client.messages
     Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
     _CommonArgs(parser,
                 include_physical_block_size_support=True,
                 vss_erase_enabled=True,
                 source_instant_snapshot_enabled=True,
                 support_pd_interface=True,
                 support_provisioned_iops=True,
                 support_user_licenses=True)
     image_utils.AddGuestOsFeaturesArg(parser, messages)
     _AddReplicaZonesArg(parser)
     kms_resource_args.AddKmsKeyResourceArg(parser,
                                            'disk',
                                            region_fallthrough=True)
     disks_flags.AddMultiWriterFlag(parser)
Exemplo n.º 13
0
  def Args(parser):
    Create.disks_arg = disks_flags.MakeDiskArg(plural=True)

    _CommonArgs(
        parser,
        include_physical_block_size_support=True,
        vss_erase_enabled=True,
        source_disk_enabled=True)
    image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.ALPHA)
    _AddReplicaZonesArg(parser)
    kms_resource_args.AddKmsKeyResourceArg(
        parser, 'disk', region_fallthrough=True)
    parser.add_argument(
        '--multi-writer',
        action='store_true',
        help=('Create the disk in shared mode so that it can be attached with '
              'read-write access to multiple VMs. Available only for zonal '
              'disks. Cannot be used with regional disks. Shared disk is '
              'exposed only as an NVMe device. Shared PD does not yet support '
              'resize and snapshot operations.'))
Exemplo n.º 14
0
def _CommonArgs(cls, parser, support_user_licenses=False):
    """Add arguments used for parsing in all command tracks."""
    cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
    cls.DISK_ARG.AddArgument(parser, operation_type='update')
    labels_util.AddUpdateLabelsFlags(parser)

    if support_user_licenses:
        scope = parser.add_mutually_exclusive_group()
        scope.add_argument(
            '--update-user-licenses',
            type=arg_parsers.ArgList(),
            metavar='LICENSE',
            action=arg_parsers.UpdateAction,
            help=
            ('List of user licenses to be updated on a disk. These user licenses'
             ' will replace all existing user licenses. If this flag is not '
             'provided, all existing user licenses will remain unchanged.'))
        scope.add_argument(
            '--clear-user-licenses',
            action='store_true',
            help=('Remove all existing user licenses on a disk.'))
Exemplo n.º 15
0
  def Run(self, args):
    holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
    client = holder.client.apitools_client
    messages = holder.client.messages

    disk_ref = disks_flags.MakeDiskArg(
        plural=False).ResolveAsResource(args, holder.resources)
    disk_info = api_util.GetDiskInfo(disk_ref, client, messages)
    disk_region = disk_info.GetDiskRegionName()

    resource_policies = []
    for policy in args.resource_policies:
      resource_policy_ref = util.ParseResourcePolicy(
          holder.resources,
          policy,
          project=disk_ref.project,
          region=disk_region)
      resource_policies.append(resource_policy_ref.SelfLink())

    return disk_info.MakeRemoveResourcePoliciesRequest(resource_policies,
                                                       holder.client)
Exemplo n.º 16
0
def _CommonArgs(cls,
                parser,
                support_user_licenses=False,
                support_architecture=False):
    """Add arguments used for parsing in all command tracks."""
    cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
    cls.DISK_ARG.AddArgument(parser, operation_type='update')
    labels_util.AddUpdateLabelsFlags(parser)

    if support_user_licenses:
        scope = parser.add_mutually_exclusive_group()
        scope.add_argument(
            '--update-user-licenses',
            type=arg_parsers.ArgList(),
            metavar='LICENSE',
            action=arg_parsers.UpdateAction,
            help=
            ('List of user licenses to be updated on a disk. These user licenses'
             ' will replace all existing user licenses. If this flag is not '
             'provided, all existing user licenses will remain unchanged.'))
        scope.add_argument('--clear-user-licenses',
                           action='store_true',
                           help='Remove all existing user licenses on a disk.')

    if support_architecture:
        scope = parser.add_mutually_exclusive_group()
        architecture_choices = sorted(['ARM64', 'X86_64'])
        scope.add_argument(
            '--update-architecture',
            choices=architecture_choices,
            help=
            ('Storage resources can be used to create boot disks compatible with '
             'different machine architectures.'))
        scope.add_argument(
            '--clear-architecture',
            action='store_true',
            help='Remove the architecture annotation on a disk.')
Exemplo n.º 17
0
 def Args(cls, parser):
     SnapshotDisks.disks_arg = disks_flags.MakeDiskArg(plural=True)
     labels_util.AddCreateLabelsFlags(parser)
     _CommonArgs(parser, snapshot_chain_enabled=cls.snapshot_chain_enabled)
Exemplo n.º 18
0
 def Args(parser):
     Delete.disks_arg = disks_flags.MakeDiskArg(plural=True)
     Delete.disks_arg.AddArgument(parser, operation_type='delete')
     parser.display_info.AddCacheUpdater(completers.DisksCompleter)
 def Args(cls, parser):
   StopAsyncReplication.disks_arg = disks_flags.MakeDiskArg(plural=False)
   StopAsyncReplication.secondary_disk_arg = disks_flags.MakeSecondaryDiskArg()
   _CommonArgs(parser)
Exemplo n.º 20
0
 def Args(cls, parser):
     Resize.disks_arg = disks_flags.MakeDiskArg(plural=True)
     _CommonArgs(parser)
 def Args(cls, parser):
     Resize.DISKS_ARG = disks_flags.MakeDiskArg(plural=True)
     _CommonArgs(parser)
Exemplo n.º 22
0
 def Args(parser):
     Describe.disk_arg = disks_flags.MakeDiskArg(plural=False)
     _CommonArgs(parser)
Exemplo n.º 23
0
 def Args(parser):
     SnapshotDisks.disks_arg = disks_flags.MakeDiskArg(plural=True)
     _CommonArgs(parser)
Exemplo n.º 24
0
 def Args(cls, parser):
     cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
     cls.DISK_ARG.AddArgument(parser, operation_type='update')
     labels_util.AddUpdateLabelsFlags(parser)
Exemplo n.º 25
0
 def Args(parser):
     AddIamPolicyBinding.disk_arg = disks_flags.MakeDiskArg(plural=False)
     AddIamPolicyBinding.disk_arg.AddArgument(
         parser, operation_type='add the IAM policy binding to')
     iam_util.AddArgsForAddIamPolicyBinding(parser)
Exemplo n.º 26
0
 def Args(cls, parser):
     cls.DISK_ARG = disks_flags.MakeDiskArg(plural=False)
     cls.DISK_ARG.AddArgument(parser)
     labels_flags.AddArgsForAddLabels(parser)
Exemplo n.º 27
0
 def Args(parser):
   Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
   _CommonArgs(parser, disks_flags.SOURCE_SNAPSHOT_ARG)
Exemplo n.º 28
0
  def Args(parser):
    Create.disks_arg = disks_flags.MakeDiskArg(plural=True)
    _CommonArgs(parser, disks_flags.SOURCE_SNAPSHOT_ARG)

    image_utils.AddGuestOsFeaturesArg(parser, base.ReleaseTrack.BETA)
 def Args(parser):
     RemoveIamPolicyBinding.disk_arg = disks_flags.MakeDiskArg(plural=False)
     RemoveIamPolicyBinding.disk_arg.AddArgument(
         parser, operation_type='remove the IAM policy binding from')
     iam_util.AddArgsForRemoveIamPolicyBinding(parser)
Exemplo n.º 30
0
 def Args(parser):
     SetIamPolicy.disk_arg = disks_flags.MakeDiskArg(plural=False)
     SetIamPolicy.disk_arg.AddArgument(
         parser, operation_type='set the IAM policy of')
     compute_flags.AddPolicyFileFlag(parser)