Пример #1
0
    def checkOptions(self):
        AuthnCommand.checkCloudEndpointOptionsOnly(self)

        if not self.vmIds and not self.options.inVmIdsFile:
            self.parser.error('Missing vm-id or input file (-i/--input)')

        super(InstanceCommand, self).checkOptions()
Пример #2
0
    def checkOptions(self):
        if not self.vmIds:
            self.parser.error('Missing vm-id')

        AuthnCommand.checkCloudEndpointOptionsOnly(self)
        PortTranslationCommand.checkCommonOptions(self)
        self._checkPrivateKeyFile()

        super(MainProgram, self).checkOptions()
Пример #3
0
    def parse(self):
        self.parser.usage = self.parser_usage
        self.parser.description = self.parser_description

        self.parser.add_option('-i', '--input', dest='inVmIdsFile',
                               help='file containing line separated vm-ids', metavar='FILE',
                               default=None)

        AuthnCommand.addCloudEndpointOptions(self.parser)

        super(InstanceCommand, self).parse()

        self.options, self.vmIds = self.parser.parse_args()
Пример #4
0
    def parse(self):
        self.parser.usage = '%prog [options] volume-uuid ...'
        self.parser.description = '''
Detach one or more persistent volumes (disks) that were dynamically
attached to a running virtual machine.  The volume-uuid arguments are
the unique identifiers of volumes to detach.
'''

        self.parser.add_option('-i', '--instance', dest='instance',
                               help='The ID of the instance to which the volume attaches', metavar='VM_ID',
                               default=0, type='int')

        StorageCommand.addPDiskEndpointOptions(self.parser)
        AuthnCommand.addCloudEndpointOptions(self.parser)

        super(MainProgram, self).parse()

        self.options, self.uuids = self.parser.parse_args()
Пример #5
0
    def checkOptions(self):

        if self.options.listType:
            return

        self._check_args()

        self.image = self.args[0]

        AuthnCommand.checkCloudEndpointOptionsOnly(self)

        if self.options.extraContextFile and not os.path.isfile(self.options.extraContextFile):
            self.parser.error('Extra context file does not exist')
        if self.options.vncListen and not Util.validateIp(self.options.vncListen):
            self.parser.error('VNC listen IP is not valid')

        MarketplaceUtil.checkEndpointOption(self.options)

        super(Runnable, self).checkOptions()
Пример #6
0
    def parse(self):
        self.parser.usage = '%prog [options] volume-uuid'

        self.parser.description = '''
Attach a persistent volume (disk) to a running virtual machine.  The
volume-uuid argument is the unique identifier of the volume (disk) to
attach.
'''

        self.parser.add_option('-i', '--instance', dest='instance',
                               help='The ID of the instance to which the volume attaches', metavar='VM_ID',
                               default=0, type='int')

        StorageCommand.addPDiskEndpointOptions(self.parser)
        AuthnCommand.addCloudEndpointOptions(self.parser)

        super(MainProgram, self).parse()

        self.options, self.uuids = self.parser.parse_args()
Пример #7
0
    def parse(self):
        Uploader.buildUploadParser(self.parser)

        self.parser.usage = '''%prog [options] image-file'''

        self.parser.description = '''
Uploads the given machine or disk image file to the persistent
disk service.  The image-file argument is the file to upload.
'''

        self.addP12CertOptions(self.parser, AuthnCommand.defaultRunOptions())

        self.options, self.args = self.parser.parse_args()
Пример #8
0
    def parse(self):
        defaultOptions = self._setDefaultOptions()

        self.parser.usage = '%prog [options] vm-id'
        self.parser.description = '''
Connects to the given virtual machine via SSH.  Automatically retries
the connection on failures. The vm-id argument is the virtual machine
identifier.
'''

        self.parser.add_option('-k', '--key', dest='userPrivateKeyFile',
                               help='SSH private key file to log on the machine. Default %s.' % defaultOptions[
                                   'userPrivateKeyFile'],
                               metavar='FILE',
                               default=defaultOptions['userPrivateKeyFile'])

        PortTranslationCommand.addCommonOptions(self.parser)
        AuthnCommand.addCloudEndpointOptions(self.parser)

        super(MainProgram, self).parse()

        self.options, self.vmIds = self.parser.parse_args()
    def parse(self):

        self.parser.usage = '%prog [options] [vm-id ...]'

        self.parser.description = '''
Provides information about the virtual machine with the given
identifiers or all virtual machine if no identifier is given.  The
vm-id arguments are the identifiers of the machines to list. All
virtual machines will be listed if no argument is given.
'''

        PortTranslationCommand.addCommonOptions(self.parser)
        AuthnCommand.addCloudEndpointOptions(self.parser)
        Monitor.addOptions(self.parser)

        self.parser.add_option('-m', dest='multi_site', action='store_true',
                               help='Print state of virtual machines on multiple sites. '
                                    '"endpoints" parameter should be set in user configuration '
                                    'file.',
                               default=False)

        super(MainProgram, self).parse()

        self.options, self.vmIds = self.parser.parse_args()
Пример #10
0
    def parse(self):
        default_options = VmManager.defaultRunOptions()

        self.parser.usage = self.parser_usage

        self.parser.description = self.parser_description

        self.parser.add_option('-k', '--key', dest='userPublicKeyFile',
                               help='SSH public key(s) (.pub) to log on the machine. Default %s. In case of multiple keys, concatenate them to the file.' %
                                    default_options['userPublicKeyFile'],
                               metavar='FILE',
                               default=default_options['userPublicKeyFile'])

        self.parser.add_option('-t', '--type', dest='instanceType',
                               help='instance type to start (see --list-types for default)', metavar='TYPE',
                               default=VmManager.DEFAULT_INSTANCE_TYPE)

        self.parser.add_option('--list-type', dest='listType',
                               help='list available instance types (deprecated)',
                               action='store_true')

        self.parser.add_option('-l', '--list-types', dest='listType',
                               help='list available instance types',
                               default=False, action='store_true')

        self.parser.add_option('--cpu', dest='vmCpu',
                               help='number of CPU cores',
                               default=None)

        self.parser.add_option('--ram', dest='vmRam',
                               help='RAM in megabytes',
                               default=None)

        self.parser.add_option('--swap', dest='vmSwap',
                               help='swap space in megabytes',
                               default=None)

        self.parser.add_option('--context-file', dest='extraContextFile', metavar='FILE',
                               help='extra context file with one key=value per line',
                               default=default_options['extraContextFile'])
        self.parser.add_option('--context', dest='extraContextData', metavar='CONTEXT',
                               help='extra context string (separate by %s)' % Util.cliLineSplitChar,
                               default=default_options['extraContextData'])

        self.parser.add_option('--context-method', dest='defaultContextMethod', metavar='METHOD',
                               help='default contextualization method (one or cloud-init)',
                               default=default_options['defaultContextMethod'])

        self.parser.add_option('--cloud-init', dest='cloudInit', metavar='PAIRS',
                               help='mimetype,file pairs (separate by %s)' % Util.cliLineSplitChar,
                               default=default_options['cloudInit'])

        self.parser.add_option('--vnc-port', dest='vncPort', metavar='PORT', type='int',
                               help='VNC port number. Note for KVM it\'s the real one, not the '
                                    'VNC port. So for VNC port 0 you should specify 5900, for '
                                    'port 1 is 5901 and so on. ',
                               default=default_options['vncPort'])

        self.parser.add_option('--vnc-listen', dest='vncListen', metavar='ADDRESS',
                               help='IP to listen on',
                               default=default_options['vncListen'])

        self.parser.add_option('--keymap', dest='keymap', metavar='LANGUAGE',
                               help='Keymap to use.',
                               default=default_options['keymap'])

        self.parser.add_option('--use-host-cpu', dest='useHostCpu',
                               help='Use host CPU extensions (flags)',
                               default=default_options['useHostCpu'],
                               action='store_true')

        self.parser.add_option('--vm-requirements', dest='vmRequirements', metavar='REQUIREMENTS',
                               help='Advanced requirements for VM placement. '
                                    'Available values depend on the cloud configuration. '
                                    'e.g. --vm-requirements \'CLUSTER = \\"test\\" & MAGICNUMBER = 42\'',
                               default=None)

        self.parser.add_option('--vm-network-model', dest='vmNetworkModel', metavar='MODEL',
                               help='NIC model. '
                                    'Default: hypervisor default.  Common value: virtio.',
                               default=None)

        self.parser.add_option('--vm-template-file', dest='vmTemplateFile', metavar='FILE',
                               help='VM template file. Default %s' % default_options['vmTemplateFile'],
                               default=default_options['vmTemplateFile'])

        self.parser.add_option('--vm-cpu-amount', dest='vmCpuAmount', metavar='CPU', type='float',
                               help='Percentage of CPU divided by 100 required for the Virtual Machine. '
                                    'Half a processor is written 0.5. No default. If not provided, CPU value from '
                                    'predefined instance types is used.',
                               default=default_options['vmCpuAmount'])

        self.parser.add_option('--vm-disks-bus', dest='vmDisksBus', metavar='BUSTYPE',
                               help='VM disks bus type defined for all disks. Overrides "disks-bus" '
                                    'element value defined in image manifest. '
                                    'Available types: %s. ' % ', '.join(VmManager.DISKS_BUS_AVAILABLE) +
                                    'If not provided, by default the value is taken from disks-bus '
                                    'element of image manifest. If the latter is not set, '
                                    'by default "%s" is assumed.' % VmManager.DISKS_BUS_DEFAULT,
                               default=default_options['vmDisksBus'])

        MarketplaceUtil.addEndpointOption(self.parser)

        AuthnCommand.addCloudEndpointOptions(self.parser)

        super(Runnable, self).parse()

        options, self.args = self.parser.parse_args()

        self._assignOptions(default_options, options)
Пример #11
0
 def checkOptions(self):
     AuthnCommand.checkCloudEndpointOptionsOnly(self)
     PortTranslationCommand.checkCommonOptions(self)
     super(MainProgram, self).checkOptions()