def Args(parser):
        flags.AddDiskScopeFlag(parser)
        parser.add_argument('--force-attach',
                            default=False,
                            action='store_true',
                            help="""\
Attach the disk to the instance even if it is currently attached to another
instance. The attachment will succeed even if detaching from the previous
instance fails at first. The server will continue trying to detach the disk from
the previous instance in the background.""")
        _CommonArgs(parser)
    def Args(parser):
        flags.AddDiskScopeFlag(parser)
        parser.add_argument('--force-attach',
                            default=False,
                            action='store_true',
                            hidden=True,
                            help="""\
Attach the disk to the instance even if there is another instance currently
attached to it. The server will attempt to detach the disk cleanly from the
existing instance but will force attach to the new instance if that's not
possible and will continue to try to detach from the previous instance in the
background.""")
        _CommonArgs(parser)
Exemple #3
0
def _Args(parser,
          support_disk_scope=False,
          support_force_attach=False,
          support_boot=False):
    """Add parser arguments to all tracks."""

    flags.INSTANCE_ARG.AddArgument(parser)

    # TODO(b/69955187): Add note about matching with name in order to mount to
    # container.
    parser.add_argument(
        '--device-name',
        help=('An optional name that indicates the disk name the guest '
              'operating system will see. (Note: Device name does not '
              'correspond to mounted volume name). Must match the disk name '
              'if the disk is going to be mounted to a container with '
              '--container-mount-disk (alpha feature).'))

    parser.add_argument('--disk',
                        help='The name of the disk to attach to the instance.',
                        required=True)

    parser.add_argument('--mode',
                        choices=MODE_OPTIONS,
                        default='rw',
                        help='Specifies the mode of the disk.')

    if support_disk_scope:
        flags.AddDiskScopeFlag(parser)

    if support_force_attach:
        parser.add_argument('--force-attach',
                            default=False,
                            action='store_true',
                            help="""\
Attach the disk to the instance even if it is currently attached to another
instance. The attachment will succeed even if detaching from the previous
instance fails at first. The server will continue trying to detach the disk from
the previous instance in the background.""")

    if support_boot:
        parser.add_argument(
            '--boot',
            action='store_true',
            help='Attach the disk to the instance as a boot disk.')

    csek_utils.AddCsekKeyArgs(parser, flags_about_creation=False)
Exemple #4
0
    def Args(parser):
        flags.INSTANCE_ARG.AddArgument(parser)
        disk_group = parser.add_mutually_exclusive_group(required=True)

        disk_group.add_argument('--disk',
                                help="""\
        Specifies a disk to detach by its resource name. If you specify a
        disk to remove by persistent disk name, then you must not specify its
        device name using the ``--device-name'' flag.
        """)

        disk_group.add_argument('--device-name',
                                help="""\
        Specifies a disk to detach by its device name, which is the name
        that the guest operating system sees. The device name is set
        at the time that the disk is attached to the instance, and needs not be
        the same as the persistent disk name. If the disk's device name is
        specified, then its persistent disk name must not be specified
        using the ``--disk'' flag.
        """)
        flags.AddDiskScopeFlag(parser)
Exemple #5
0
 def Args(parser):
     DetachDisk.Args(parser)
     flags.AddDiskScopeFlag(parser)