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. [转]iOS Anti-Debugging Protections

    source-1: http://www.coredump.gr/articles/ios-anti-debugging-protections-part-1/ source-2: http://ww ...

  2. 【又长见识了】函数传参,params参数,ref和out参数详解

    一.原来函数这样传参 先看一个函数和函数调用. static void Main(string[] args) { ; Test(num);//局部变量在使用之前赋值 //Test(10); //直接 ...

  3. 序列化json对象,通过ajax传入asp.net mvc后台

    序列化json对象,通过ajax传入asp.net mvc后台 序列化json对象,通过ajax传入asp.net mvc后台   今天遇到一个问题,准备把组织好的json对象通过jquery.aja ...

  4. (转)JS中公共/私有变量和方法

    私有变量 在对象内部使用'var'关键字来声明,而且它只能被私有函数和特权方法访问. 私有函数 在对象的构造函数里声明(或者是通过var functionName=function(){...}来定义 ...

  5. JS左侧菜单-02

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> <html xmlns=" ...

  6. mosquitto awareness when before it's being compiling, and you do settings and testing

    Mostly, this clearify the usage of   ' mosquitto.conf ' in easy-understanding language.   1. compile ...

  7. 提高你的Java代码质量吧:不要让类型默默转换

    一.分析  在Java运算中的类型转换,是先运算在进行类型转换的.具体场景如下. 二.场景  在如下程序中: public class Client{ public static final int ...

  8. 第一章 引言--《设计模式-可复用面向对象软件的基础》Erich Gamma

    第一章 引言 本章主要是让我们大致明白设计模式是干嘛用的,模式分类,设计模式如何解决设计问题以及几种常见的面向对象设计中软件的复用方法. 1.什么是设计模式? 个人理解概括,设计模式是对一类问题的抽象 ...

  9. php中traits学习笔记

    traits学习 越来越多的框架和代码开始使用traits方式去组织一些功能,这是非常高效的代码组织结构. 通过trait来减少不必要的类继承关系,让代码更加复用,形成可以拔插的代码集合. 通过逗号分 ...

  10. Java项目中打开本地文件的方法

    1:其中saveAddress 为已知本地文件全路径: Desktop.getDesktop().open(new File(saveAddress));