trove instance service 总结

时间:2023-01-23 09:46:25
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. sshpass----------------sshfs--sftp(sublime)

    源码下载地址:http://sourceforge.net/projects/sshpass/   tar -zxvf sshpass-1.05.tar.gz cd sshpass-1.05 ./co ...

  2. Java内存区域

    1.运行时数据区域 java虚拟机在执行java程序的过程中会将它管理的内存区域分为若干个不同的数据区域.这些区域有各自的服务对象,创建以及销毁时间,有的内存区域随着虚拟机的启动和关闭而创建和销毁,有 ...

  3. Python-内置类属性

    Python内置类属性 __dict__ : 类的属性(包含一个字典,由类的数据属性组成) __doc__ :类的文档字符串 __name__: 类名 __module__: 类定义所在的模块(类的全 ...

  4. eclipse 引用自己开发的模块

    这样就可以 生成的是LIB 工程需要设置“Is Library”

  5. leetcode96 Unique Binary Search Trees

    题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For e ...

  6. JQuery实现回车代替Tab键(按回车跳到下一栏)

    一个提交按钮以后,用户如果按了键盘的回车键,默认情况下,就会提交这个表单了.这样对于用户输入各个表单项目,用户体验很不好,输入完一个项目,或者用鼠标选择下一个项目,或者用键盘的Tab键选中下一个项目. ...

  7. 【转】Ansys 13.0 flexlm not running完美解决方案

    http://jingyan.baidu.com/article/af9f5a2dd9843a43150a4550.html 实测,12.1 用此方法问题同样得解.

  8. iOS UILabel UITextView UIButton 等等显示文本行间距

    iOS UILabel  UITextView UIButton 等等显示文本行间距都用如下方法 NSMutableParagraphStyle *paragraphStyle = [[NSMutab ...

  9. C#中关于表达式与委托在EF中的不同表现总结

    Func<Invoice, bool> func = x => x.State == InvoiceState.Created; Expression<Func<Invo ...

  10. wifi的主动扫描和被动扫描

    要实现wifi上的探针模块,简单了了解了802.11中的各种帧,对一些帧的发送频率和方式也有简单了解.不过了解的都不够细致.只是简单知道手机打开wifi后回不停的向外发送probe request这个 ...