Ejemplo n.º 1
0
    def testDeploySSHCluster(self):
        options = VmManager.defaultRunOptions()
        options.update({'username': ClusterTest.username,
                        'password': ClusterTest.password,
                        'mpi_machine_file': True,
                        'instanceType': self.instanceType,
                        'cluster_admin': 'root',
                        'cluster_user': '******',
                        'master_vmid': None,
                        'tolerate_failures': False,
                        'clean_after_failure': False,
                        'include_master': True,
                        'shared_folder': None,
                        'add_packages': None,
                        'ssh_hostbased': True,
                        'instanceNumber': self.instanceNumber,
                        'verboseLevel': 0,
                        'marketplaceEndpoint': 'https://marketplace.stratuslab.eu'})
        configHolder = ConfigHolder(options)
        runner = VmManagerFactory.create(self.image, configHolder)
        cluster = Cluster(configHolder, runner, options['master_vmid'])
        runner.runInstance()

        self.assertTrue(cluster.deploy() in [0, 128])

        runner.killInstances(runner.vmIds)
Ejemplo n.º 2
0
    def __createRunner(self):
        self.configHolder.set("vmName", "%s: %s" % (self.vmName, Util.getTimeInIso8601()))
        self.configHolder.set("noCheckImageUrl", True)

        self.configHolder.set("saveDisk", True)

        self.runner = VmManagerFactory.create(self.image, self.configHolder)

        self.runner.updateCreateImageTemplateData(self._getCreateImageTemplateDict())
Ejemplo n.º 3
0
    def doWork(self):
        configHolder = ConfigHolder(self.options.__dict__)
        runner = VmManagerFactory.create(self.image, configHolder)
        cluster = Cluster(configHolder, runner, self.options.master_vmid)

        printAction('Starting cluster')
        runner.runInstance()

        cluster.deploy()

        printStep('Done!')
Ejemplo n.º 4
0
    def _createRunner(self, withLocalNetwork=False, requestedIpAddress=None, persistentDiskUUID=None, image=None):
        Util.generateSshKeyPair(self.sshKey)

        if not image:
            image = self.image

        options = VmManagerInstance.defaultRunOptions()
        options["username"] = self.testUsername
        options["password"] = self.testPassword
        options["userPublicKeyFile"] = self.sshKeyPub
        options["verboseLevel"] = self.verboseLevel
        options["specificAddressRequest"] = requestedIpAddress
        options["persistentDiskUUID"] = persistentDiskUUID
        options["pdiskEndpoint"] = self.pdiskEndpoint
        options["marketplaceEndpoint"] = self.marketplaceEndpoint

        if withLocalNetwork:
            options["isLocalIp"] = True

        configHolder = ConfigHolder(options)
        return VmManagerFactory.create(image, configHolder)
Ejemplo n.º 5
0
    def _create_runner(self, name, size, image, location=None, auth=None):

        location = location or self.default_location

        holder = self._get_config_section(location)

        if auth is None:
            self._insert_required_run_option_defaults(holder,
                                                      ['userPublicKeyFile'])
        else:
            self._insert_required_run_option_defaults(holder)

        holder.set('vmName', name)

        pubkey_file = None
        if isinstance(auth, NodeAuthSSHKey):
            _, pubkey_file = tempfile.mkstemp(suffix='_pub.key', prefix='ssh_')
            with open(pubkey_file, 'w') as f:
                f.write(auth.pubkey)

            holder.set('userPublicKeyFile', pubkey_file)

        # The cpu attribute is only included in the StratusLab
        # subclass of NodeSize.  Recover if the user passed in a
        # normal NodeSize; default to 1 CPU in this case.
        try:
            cpu = size.cpu
        except AttributeError:
            cpu = 1

        holder.set('vmCpu', cpu)
        holder.set('vmRam', size.ram)
        holder.set('vmSwap', size.disk)

        runner = VmManagerFactory.create(image.id, holder)

        if pubkey_file:
            os.remove(pubkey_file)

        return runner
Ejemplo n.º 6
0
    def doWork(self):
        configHolder = ConfigHolder(self.options.__dict__, self.config)

        if self.options.saveDisk:
            creator = Creator(self.image, configHolder)
            creator.createRunner()
            runner = creator.runner
        else:
            runner = VmManagerFactory.create(self.image, configHolder)

        if self.options.listType:
            print runner.listInstanceTypes()
        else:
            vmInfo = runner.runInstance(details=True)

            # TODO: This is anti-intuitive and should be reviewed.
            #
            # To keep compatibility with the previous output, this will
            # only print something when quiet is set.  The 'normal' output
            # will be printed via INFO logging statements in the code.
            if self.options.quiet > 0:
                self._printShortResults(vmInfo)
Ejemplo n.º 7
0
 def _get_runner(self):
     configHolder = ConfigHolder(self.options.__dict__)
     return VmManagerFactory.create(None, configHolder)