コード例 #1
0
ファイル: resources.py プロジェクト: AlBartash/mcv-consoler
    def _create_os_keypair(self):
        nova = self.ctx.access.nova

        name = config.tool_vm_keypair_name
        for idx in range(2):
            try:
                keypair = nova.keypairs.create(name)
            except self.ctx.access.nova_exc.Conflict:
                LOG.debug('Remove existing(outdated) keypair "%s"', name)
                nova.keypairs.get(name).delete()
                continue
            break
        else:
            raise exceptions.FrameworkError('Unable to create keypair object')

        self.resource_pool.add(resource.OSObjectResource(keypair), True)

        work_dir = self.ctx.work_dir
        key_path = work_dir.resource(
            work_dir.RES_TOOL_VM_SSH_KEY, lookup=False)
        ssh.save_private_key(key_path, keypair.private_key)

        self.resource_pool.add(resource.FileResource(key_path), True)

        return keypair
コード例 #2
0
ファイル: router.py プロジェクト: AlBartash/mcv-consoler
    def get_os_ssh_key(self):
        work_dir = self.ctx.work_dir_global
        try:
            work_dir.resource(work_dir.RES_OS_SSH_KEY)
            LOG.debug('Use OS ssh key provide by user.')
            return
        except mcv_consoler.exceptions.FileResourceNotFoundError:
            pass

        fuel = self._ssh_connect(self.SSH_DEST_FUELMASTER, connect=True)
        proc = fuel.exec_cmd(
            "cat {}".format(self.os_data['fuel']['cert']),
            exc=True, hide_stdout=True)

        path = work_dir.resource(work_dir.RES_OS_SSH_KEY, lookup=False)
        ssh.save_private_key(path, proc.stdout)
        LOG.debug('Saving RSA key to file %s...', path)
コード例 #3
0
ファイル: consoler.py プロジェクト: AlBartash/mcv-consoler
    def _collect_predefined_data(self):
        work_dir = self.ctx.work_dir_global
        args = self.ctx.args

        if args.os_ssh_key:
            dest = work_dir.resource(work_dir.RES_OS_SSH_KEY, lookup=False)
            ssh.save_private_key(dest, args.os_ssh_key.read())

        for opt, res in (
                ('os_openrc', work_dir.RES_OS_OPENRC),
                ('os_fuelclient_settings', work_dir.RES_FUELCLIENT_SETTINGS)):
            opt = getattr(args, opt)
            if not opt:
                continue

            with open(
                    work_dir.resource(res, lookup=False), 'wt') as dest:
                shutil.copyfileobj(opt, dest)