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)
评论列表
文章目录