def create(self, req, body, tenant_id):
# TODO(hub-cap): turn this into middleware
LOG.info(_LI("Creating a database instance for tenant '%s'"),
tenant_id)
LOG.debug("req : '%s'\n\n", strutils.mask_password(req))
LOG.debug("body : '%s'\n\n", strutils.mask_password(body))
context = req.environ[wsgi.CONTEXT_KEY]
context.notification = notification.DBaaSInstanceCreate(context,
request=req)
datastore_args = body['instance'].get('datastore', {})
datastore, datastore_version = (
datastore_models.get_datastore_version(**datastore_args))
image_id = datastore_version.image_id
name = body['instance']['name']
flavor_ref = body['instance']['flavorRef']
flavor_id = utils.get_id_from_href(flavor_ref) configuration = self._configuration_parse(context, body)
databases = populate_validated_databases(
body['instance'].get('databases', []))
database_names = [database.get('_name', '') for database in databases]
users = None
try:
users = populate_users(body['instance'].get('users', []),
database_names)
except ValueError as ve:
raise exception.BadRequest(msg=ve) if 'volume' in body['instance']:
volume_info = body['instance']['volume']
volume_size = int(volume_info['size'])
volume_type = volume_info.get('type')
else:
volume_size = None
volume_type = None if 'restorePoint' in body['instance']:
backupRef = body['instance']['restorePoint']['backupRef']
backup_id = utils.get_id_from_href(backupRef)
else:
backup_id = None availability_zone = body['instance'].get('availability_zone')
nics = body['instance'].get('nics') slave_of_id = body['instance'].get('replica_of',
# also check for older name
body['instance'].get('slave_of'))
replica_count = body['instance'].get('replica_count')
modules = body['instance'].get('modules')
locality = body['instance'].get('locality')
if locality:
locality_domain = ['affinity', 'anti-affinity']
locality_domain_msg = ("Invalid locality '%s'. "
"Must be one of ['%s']" %
(locality,
"', '".join(locality_domain)))
if locality not in locality_domain:
raise exception.BadRequest(msg=locality_domain_msg)
if slave_of_id:
dupe_locality_msg = (
'Cannot specify locality when adding replicas to existing '
'master.')
raise exception.BadRequest(msg=dupe_locality_msg) instance = models.Instance.create(context, name, flavor_id,
image_id, databases, users,
datastore, datastore_version,
volume_size, backup_id,
availability_zone, nics,
configuration, slave_of_id,
replica_count=replica_count,
volume_type=volume_type,
modules=modules,
locality=locality) view = views.InstanceDetailView(instance, req=req)
return wsgi.Result(view.data(), 200) 基本就是四步走,首先是请求上下文,然后创建实例对象,然后操作,最后返回wsgi

trove instance service 总结的更多相关文章

  1. SQL Server 2012 Managed Service Account

    原创地址:http://www.cnblogs.com/jfzhu/p/4007472.html 转载请注明出处 (一)Windows服务使用的登陆帐号 Windows服务只有登录到某一帐户的情况下才 ...

  2. Guice 学习(六)使用Provider注入服务( Provider Inject Service)

    1.定义接口 package com.guice.providerInject; import com.google.inject.ProvidedBy; public interface Servi ...

  3. trove datastore 浅析

    以下代码来自trove/datastore该目录下一共有4个文件__init__,views,models,service大概关系(主要是wsgi吧,没仔细学过,简单的从代码上做推测),service ...

  4. Open-Source Service Discovery

    Service discovery is a key component of most distributed systems and service oriented architectures. ...

  5. 【转帖】如何在redhat单机服务器上运行postgresql的多个实例(howto run multiple postgresql instance on one redhat server)

    Running multiple PostgreSQL 9.2 Instances on one server in CentOS 6/RHEL 6/Fedora 原帖网站速度很慢,故转帖在此 Thi ...

  6. OpenStack trove原理及配置实践

    DBaaS是什么? 字面上理解数据库即是服务,简单来说就是以服务的形式为用户提供数据库服务. 在云平台上使用trove有什么优势? 简化IT操作流程,降低使用数据库使用门槛举个例子,曾经我搭建一个LA ...

  7. openstack Icehouse发布

    OpenStack 2014.1 (Icehouse) Release Notes General Upgrade Notes Windows packagers should use pbr 0.8 ...

  8. kolla queens on centos7.5 -all in one

    目录 环境准备 开始配置 快照,快照,快照 pull镜像并部署 登录配置OpenStack 环境准备 我这里用workstation创建了一个虚拟机,安装centos7.5 mini系统,这台虚拟机上 ...

  9. OpenStack 2014.1(Icehouse) 更新说明

    OpenStack 2014.1(Icehouse) 更新说明 1.综合升级说明 Ÿ   Windows安装包应使用PBR 0.8版本,以避免发生bug1294246 Ÿ   log-config选项 ...

随机推荐

  1. Load ContextCLR 探测

    目录 背景Load ContextCLR 探测过程弱签名程序集的探测过程强签名程序集的探测过程Default ContextLoad-From ContextNo ContextRelfection- ...

  2. UML类图的常见关系1

    设计模式之UML类图的常见关系(一)   本篇会讲解在UML类图中,常见几种关系: 泛化(Generalization),依赖(Dependency),关联(Association),聚合(Aggre ...

  3. Python 用SMTP发送邮件

    一.简介 上面介绍了传统邮件的生成和解析,这些都是non-internet,也就是不需要网络就可一完成的.那么当生成了邮件,下一步就是发送了,本文就讲解利用SMTP协议发送邮件. 正如SMTP(Sim ...

  4. jQuery $.ajaxSend()

    语法: $("#msg").ajaxSend(function(evt,request,settings){}); AJAX请求发送前执行函数.Ajax事件. XMLHttpReq ...

  5. nginx开启后主机无法访问虚拟机的nginx解决方案

    如果IP可以通的话 一般是防火墙引起 方法1.cat /etc/sysconfig/iptables # Generated by iptables-save v1. :: *filter :INPU ...

  6. 依赖注入(IOC)

    依赖注入(IOC) 背景介绍 在设计模式中,尤其是结构型模式很多时候解决的就是对象间的依赖关系,变依赖具体为依赖抽象.平时开发中如果发现客户程序依赖某个或某类对象,我们常常会对他们进行一次抽象,形成抽 ...

  7. html5 人物行走

    键盘方向键控制人物上下左右行走 演示地址 点击打开链接 MYCode <html> <head> <meta charset=utf-8> <title> ...

  8. C#新功能--命名参数与可选参数

    C#新功能--命名参数与可选参数 可能是篇幅太短了,又被打入冷宫了.先重发一篇加上可选参数.本来不想加这个呢,因为可选参数可能大家用的会多点.其实这 两个在VB中早就有了,在C#中,只有在.net4以 ...

  9. 2013 Esri全球用户大会之元数据支持

    1.1 是否支持FGDC CSDGMArcGIS是否支持FGDC CSDGM和North American Profile (NAP)元数据标准?如何支持? 支持,从ArcGIS forDesktop ...

  10. table指定位置添加行

    <html> <head> <script type="text/javascript"> //global var //to find the ...