__init__.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:ramdisk-func-test 作者: openstack 项目源码 文件源码
def do_GET(self):
        LOG.info('Got GET request: %s', self.path)
        fake_check = re.match(r'/fake', self.path)
        tenant_images_match = re.match(r'/tenant_images/(.*)$', self.path)
        deploy_steps_match = re.match(
            r'/v1/nodes/([^/]*)/vendor_passthru/deploy_steps', self.path)

        if fake_check is not None:
            LOG.info("This is 'fake' request.")
            self.path = os.path.join(self.ctx.htdocs, 'stubfile')
        elif tenant_images_match is not None:
            LOG.info("This is 'tenant-images' request: %s", self.path)
            tenant_image = tenant_images_match.group(1)
            self.path = os.path.join(self.ctx.images_path, tenant_image)
        elif deploy_steps_match is not None:
            with open('{}.pub'.format(self.ctx.ssh_key)) as data:
                ssh_key = data.read().rstrip()

            data = {
                'name': 'inject-ssh-keys',
                'payload': {
                    'ssh-keys': {
                        'root': [ssh_key]
                    }
                }
            }
            tmp = tempfile.NamedTemporaryFile()
            json.dump(data, tmp)
            tmp.flush()

            self.path = tmp.name

        return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号