示例#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 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()
示例#3
0
文件: Runnable.py 项目: remyd1/client
    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()
示例#4
0
文件: Runnable.py 项目: remyd1/client
    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('--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-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)