本文整理汇总了Python中trove.datastore.models.get_datastore_version函数的典型用法代码示例。如果您正苦于以下问题:Python get_datastore_version函数的具体用法?Python get_datastore_version怎么用?Python get_datastore_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_datastore_version函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: show
def show(self, req, tenant_id, datastore, id, name):
self.authorize_request(req, 'show')
ds, ds_version = ds_models.get_datastore_version(
type=datastore, version=id)
rule = models.DatastoreConfigurationParameters.load_parameter_by_name(
ds_version.id, name)
return wsgi.Result(views.ConfigurationParameterView(rule).data(), 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:7,代码来源:service.py
示例2: index
def index(self, req, tenant_id, datastore, id):
ds, ds_version = ds_models.get_datastore_version(
type=datastore, version=id)
rules = models.DatastoreConfigurationParameters.load_parameters(
ds_version.id)
return wsgi.Result(views.ConfigurationParametersView(rules).data(),
200)
开发者ID:cp16net,项目名称:trove,代码行数:7,代码来源:service.py
示例3: index
def index(self, req, tenant_id, datastore, id):
ds, ds_version = ds_models.get_datastore_version(
type=datastore, version=id)
rules = configurations.get_validation_rules(
datastore_manager=ds_version.manager)
return wsgi.Result(views.ConfigurationParametersView(rules).data(),
200)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:7,代码来源:service.py
示例4: create
def create(self, req, body, tenant_id):
LOG.debug("req : '%s'\n\n" % req)
LOG.debug("body : '%s'\n\n" % req)
name = body['configuration']['name']
description = body['configuration'].get('description')
values = body['configuration']['values']
datastore_args = body['configuration'].get('datastore', {})
datastore, datastore_version = (
ds_models.get_datastore_version(**datastore_args))
configItems = []
if values:
# validate that the values passed in are permitted by the operator.
ConfigurationsController._validate_configuration(
body['configuration']['values'],
datastore_manager=datastore_version.manager)
for k, v in values.iteritems():
configItems.append(ConfigurationParameter(
configuration_key=k,
configuration_value=v))
cfg_group = models.Configuration.create(name, description, tenant_id,
datastore.id,
datastore_version.id)
cfg_group_items = models.Configuration.create_items(cfg_group.id,
values)
view_data = views.DetailedConfigurationView(cfg_group,
cfg_group_items)
return wsgi.Result(view_data.data(), 200)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:32,代码来源:service.py
示例5: create
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')
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)
view = views.InstanceDetailView(instance, req=req)
return wsgi.Result(view.data(), 200)
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:60,代码来源:service.py
示例6: create
def create(self, req, body, tenant_id):
# TODO(hub-cap): turn this into middleware
LOG.info(_("Creating a database instance for tenant '%s'") % tenant_id)
LOG.info(logging.mask_password(_("req : '%s'\n\n") % req))
LOG.info(logging.mask_password(_("body : '%s'\n\n") % body))
context = req.environ[wsgi.CONTEXT_KEY]
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_size = int(body['instance']['volume']['size'])
else:
volume_size = None
if 'restorePoint' in body['instance']:
backupRef = body['instance']['restorePoint']['backupRef']
backup_id = utils.get_id_from_href(backupRef)
else:
backup_id = None
if 'availability_zone' in body['instance']:
availability_zone = body['instance']['availability_zone']
else:
availability_zone = None
if 'nics' in body['instance']:
nics = body['instance']['nics']
else:
nics = None
if 'slave_of' in body['instance']:
slave_of_id = body['instance']['slave_of']
else:
slave_of_id = None
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)
view = views.InstanceDetailView(instance, req=req)
return wsgi.Result(view.data(), 200)
开发者ID:B-Rich,项目名称:trove,代码行数:60,代码来源:service.py
示例7: load_datastore_configuration_parameters
def load_datastore_configuration_parameters(datastore, datastore_version, config_file):
get_db_api().configure_db(CONF)
(ds, ds_v) = dstore_models.get_datastore_version(type=datastore, version=datastore_version)
with open(config_file) as f:
config = json.load(f)
for param in config["configuration-parameters"]:
create_or_update_datastore_configuration_parameter(
param["name"], ds_v.id, param["restart_required"], param["type"], param.get("max"), param.get("min")
)
开发者ID:rmyers,项目名称:trove,代码行数:9,代码来源:models.py
示例8: show
def show(self, req, tenant_id, datastore, id, name):
ds, ds_version = ds_models.get_datastore_version(
type=datastore, version=id)
rules = configurations.get_validation_rules(
datastore_manager=ds_version.manager)
for rule in rules['configuration-parameters']:
if rule['name'] == name:
return wsgi.Result(
views.ConfigurationParametersView(rule).data(), 200)
raise exception.ConfigKeyNotFound(key=name)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:10,代码来源:service.py
示例9: index
def index(self, req, tenant_id):
context = req.environ[wsgi.CONTEXT_KEY]
datastore = req.GET.get('datastore', '')
if datastore and datastore.lower() != models.Modules.MATCH_ALL_NAME:
ds, ds_ver = datastore_models.get_datastore_version(
type=datastore)
datastore = ds.id
modules = models.Modules.load(context, datastore=datastore)
view = views.ModulesView(modules)
return wsgi.Result(view.data(), 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:10,代码来源:service.py
示例10: create
def create(self, req, body, tenant_id):
LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
LOG.info(_("req : '%s'\n\n") % req)
LOG.info(_("body : '%s'\n\n") % body)
context = req.environ[wsgi.CONTEXT_KEY]
name = body['cluster']['name']
datastore_args = body['cluster'].get('datastore', {})
datastore, datastore_version = (
datastore_models.get_datastore_version(**datastore_args))
# TODO(saurabhs): add extended_properties to apischema
extended_properties = body['cluster'].get('extended_properties', {})
try:
clusters_enabled = (CONF.get(datastore_version.manager)
.get('cluster_support'))
except NoSuchOptError:
clusters_enabled = False
if not clusters_enabled:
raise exception.ClusterDatastoreNotSupported(
datastore=datastore.name,
datastore_version=datastore_version.name)
nodes = body['cluster']['instances']
instances = []
for node in nodes:
flavor_id = utils.get_id_from_href(node['flavorRef'])
volume_size = volume_type = nics = availability_zone = None
if 'volume' in node:
volume_size = int(node['volume']['size'])
volume_type = node['volume'].get('volume_type')
if 'nics' in node:
nics = node['nics']
if 'availability_zone' in node:
availability_zone = node['availability_zone']
instances.append({"flavor_id": flavor_id,
"volume_size": volume_size,
"volume_type": volume_type,
"nics": nics,
"availability_zone": availability_zone})
context.notification = notification.DBaaSClusterCreate(context,
request=req)
with StartNotification(context, name=name, datastore=datastore.name,
datastore_version=datastore_version.name):
cluster = models.Cluster.create(context, name, datastore,
datastore_version, instances,
extended_properties)
view = views.load_view(cluster, req=req, load_servers=False)
return wsgi.Result(view.data(), 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:53,代码来源:service.py
示例11: update
def update(self, req, body, tenant_id, id):
LOG.info(_("Updating configuration for tenant id %s") % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
group = models.Configuration.load(context, id)
datastore_args = body["configuration"].get("datastore", {})
datastore, datastore_version = ds_models.get_datastore_version(**datastore_args)
instances = instances_models.DBInstance.find_all(
tenant_id=context.tenant, configuration_id=id, deleted=False
).all()
# if name/description are provided in the request body, update the
# model with these values as well.
if "name" in body["configuration"]:
group.name = body["configuration"]["name"]
if "description" in body["configuration"]:
group.description = body["configuration"]["description"]
"""validate if params are valid"""
is_configuration_valid = False
validation_result = KSC_ConfigurationsController.validate_configuration(
context, body["configuration"]["values"], datastore_manager=datastore_version.manager
)
if instances:
current_config = KSC_Configuration.load(context, id)
validation_dynamic_result = KSC_Configuration.validate_dynamic_params(
context, current_config, instances, body["configuration"]["values"], dynamic_param=True
)
if validation_result or validation_dynamic_result:
if validation_dynamic_result:
validation_result.update(validation_dynamic_result)
elif not validation_result and not validation_dynamic_result:
is_configuration_valid = True
else:
if not validation_result:
is_configuration_valid = True
result = {"is_validate_pass": is_configuration_valid, "validation_result": validation_result}
if validation_result:
return wsgi.Result(result, 400)
else:
deleted_at = datetime.utcnow()
models.Configuration.remove_all_items(context, group.id, deleted_at)
LOG.info(_("loaded configuration instances: %s") % instances)
items = self.configuration_items_list(group, body["configuration"])
models.Configuration.save(context, group, items, instances)
result["is_validate_pass"] = is_configuration_valid
return wsgi.Result(result, 202)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:52,代码来源:service.py
示例12: validate_datastore
def validate_datastore(datastore, datastore_version):
datastore_id = None
datastore_version_id = None
if datastore:
ds, ds_ver = datastore_models.get_datastore_version(
type=datastore, version=datastore_version)
datastore_id = ds.id
if datastore_version:
datastore_version_id = ds_ver.id
elif datastore_version:
msg = _("Cannot specify version without datastore")
raise exception.BadRequest(message=msg)
return datastore_id, datastore_version_id
开发者ID:bhaskarduvvuri,项目名称:trove,代码行数:13,代码来源:models.py
示例13: create
def create(self, req, body, tenant_id):
LOG.debug("req : '%s'\n\n" % req)
LOG.debug("body : '%s'\n\n" % req)
context = req.environ[wsgi.CONTEXT_KEY]
policy.authorize_on_tenant(context, 'configuration:create')
context.notification = notification.DBaaSConfigurationCreate(
context, request=req)
name = body['configuration']['name']
description = body['configuration'].get('description')
values = body['configuration']['values']
msg = _("Creating configuration group on tenant "
"%(tenant_id)s with name: %(cfg_name)s")
LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})
datastore_args = body['configuration'].get('datastore', {})
datastore, datastore_version = (
ds_models.get_datastore_version(**datastore_args))
with StartNotification(context, name=name, datastore=datastore.name,
datastore_version=datastore_version.name):
configItems = []
if values:
# validate that the values passed in are permitted by the
# operator.
ConfigurationsController._validate_configuration(
body['configuration']['values'],
datastore_version,
models.DatastoreConfigurationParameters.load_parameters(
datastore_version.id))
for k, v in values.items():
configItems.append(DBConfigurationParameter(
configuration_key=k,
configuration_value=v))
cfg_group = models.Configuration.create(name, description,
tenant_id, datastore.id,
datastore_version.id)
with EndNotification(context, configuration_id=cfg_group.id):
cfg_group_items = models.Configuration.create_items(
cfg_group.id, values)
view_data = views.DetailedConfigurationView(cfg_group,
cfg_group_items)
return wsgi.Result(view_data.data(), 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:47,代码来源:service.py
示例14: load_datastore_configuration_parameters
def load_datastore_configuration_parameters(datastore,
datastore_version,
config_file):
get_db_api().configure_db(CONF)
(ds, ds_v) = dstore_models.get_datastore_version(
type=datastore, version=datastore_version, return_inactive=True)
with open(config_file) as f:
config = json.load(f)
for param in config['configuration-parameters']:
create_or_update_datastore_configuration_parameter(
param['name'],
ds_v.id,
param['restart_required'],
param['type'],
param.get('max'),
param.get('min'),
)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:17,代码来源:models.py
示例15: data
def data(self):
module_dict = dict(
id=self.module.id,
name=self.module.name,
type=self.module.type,
description=self.module.description,
tenant_id=self.module.tenant_id,
datastore_id=self.module.datastore_id,
datastore_version_id=self.module.datastore_version_id,
auto_apply=self.module.auto_apply,
priority_apply=self.module.priority_apply,
apply_order=self.module.apply_order,
is_admin=self.module.is_admin,
md5=self.module.md5,
visible=self.module.visible,
created=self.module.created,
updated=self.module.updated)
# add extra data to make results more legible
if self.module.tenant_id:
# This should be the tenant name, but until we figure out where
# to get it from, use the tenant_id
tenant = self.module.tenant_id
else:
tenant = models.Modules.MATCH_ALL_NAME
module_dict["tenant"] = tenant
datastore = self.module.datastore_id
datastore_version = self.module.datastore_version_id
if datastore:
if datastore_version:
ds, ds_ver = (
datastore_models.get_datastore_version(
type=datastore, version=datastore_version))
datastore = ds.name
datastore_version = ds_ver.name
else:
ds = datastore_models.Datastore.load(datastore)
datastore = ds.name
datastore_version = models.Modules.MATCH_ALL_NAME
else:
datastore = models.Modules.MATCH_ALL_NAME
datastore_version = models.Modules.MATCH_ALL_NAME
module_dict["datastore"] = datastore
module_dict["datastore_version"] = datastore_version
return {"module": module_dict}
开发者ID:Tesora,项目名称:tesora-trove,代码行数:45,代码来源:views.py
示例16: edit
def edit(self, req, body, tenant_id, id):
context = req.environ[wsgi.CONTEXT_KEY]
group = models.Configuration.load(context, id)
datastore_args = body["configuration"].get("datastore", {})
datastore, datastore_version = ds_models.get_datastore_version(**datastore_args)
instances = instances_models.DBInstance.find_all(
tenant_id=context.tenant, configuration_id=id, deleted=False
).all()
LOG.info(_("loaded configuration instances: %s") % instances)
"""validate if params are valid"""
is_configuration_valid = False
validation_result = KSC_ConfigurationsController.validate_configuration(
context, body["configuration"]["values"], datastore_manager=datastore_version.manager
)
if instances:
current_config = KSC_Configuration.load(context, id)
validation_dynamic_result = (
KSC_Configuration.validate_dynamic_params(
context, current_config, instances, body["configuration"]["values"], dynamic_param=True
)
or {}
)
if validation_result or validation_dynamic_result:
validation_result.update(validation_dynamic_result)
elif not validation_result and not validation_dynamic_result:
is_configuration_valid = True
else:
if not validation_result:
is_configuration_valid = True
result = {"is_validate_pass": is_configuration_valid, "validation_result": validation_result}
if validation_result:
return wsgi.Result(result, 400)
else:
items = self.configuration_items_list(group, body["configuration"])
models.Configuration.save(context, group, items, instances)
result["is_validate_pass"] = is_configuration_valid
return wsgi.Result(result, 202)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:44,代码来源:service.py
示例17: create
def create(self, req, body, tenant_id):
LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
LOG.info(_("req : '%s'\n\n") % req)
LOG.info(_("body : '%s'\n\n") % body)
context = req.environ[wsgi.CONTEXT_KEY]
name = body["cluster"]["name"]
datastore_args = body["cluster"].get("datastore", {})
datastore, datastore_version = datastore_models.get_datastore_version(**datastore_args)
try:
clusters_enabled = CONF.get(datastore_version.manager).get("cluster_support")
except NoSuchOptError:
clusters_enabled = False
if not clusters_enabled:
raise exception.ClusterDatastoreNotSupported(
datastore=datastore.name, datastore_version=datastore_version.name
)
nodes = body["cluster"]["instances"]
instances = []
for node in nodes:
flavor_id = utils.get_id_from_href(node["flavorRef"])
volume_size = nics = availability_zone = None
if "volume" in node:
volume_size = int(node["volume"]["size"])
if "nics" in node:
nics = node["nics"]
if "availability_zone" in node:
availability_zone = node["availability_zone"]
instances.append(
{
"flavor_id": flavor_id,
"volume_size": volume_size,
"nics": nics,
"availability_zone": availability_zone,
}
)
cluster = models.Cluster.create(context, name, datastore, datastore_version, instances)
view = views.load_view(cluster, req=req, load_servers=False)
return wsgi.Result(view.data(), 200)
开发者ID:henrylv206,项目名称:trove,代码行数:44,代码来源:service.py
示例18: create
def create(self, req, body, tenant_id):
LOG.debug("req : '%s'\n\n" % req)
LOG.debug("body : '%s'\n\n" % req)
context = req.environ[wsgi.CONTEXT_KEY]
name = body["configuration"]["name"]
description = body["configuration"].get("description")
values = body["configuration"]["values"]
datastore_args = body["configuration"].get("datastore", {})
datastore, datastore_version = ds_models.get_datastore_version(**datastore_args)
configItems = []
validation_result = {}
is_configuration_valid = True
if values:
# validate that the values passed in are permitted by the operator.
"""validate if params are valid"""
validation_result = KSC_ConfigurationsController.validate_configuration(
context, body["configuration"]["values"], datastore_manager=datastore_version.manager
)
for k, v in values.iteritems():
configItems.append(ConfigurationParameter(configuration_key=k, configuration_value=v))
if len(validation_result):
is_configuration_valid = False
result = {"is_validate_pass": is_configuration_valid, "validation_result": validation_result}
return wsgi.Result(result, 400)
else:
result = {"is_validate_pass": is_configuration_valid, "validation_result": validation_result}
cfg_group = models.Configuration.create(name, description, tenant_id, datastore.id, datastore_version.id)
cfg_group_items = models.Configuration.create_items(cfg_group.id, values)
view_data = views.DetailedConfigurationView(cfg_group, cfg_group_items)
result.update(view_data.data())
return wsgi.Result(result, 200)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:39,代码来源:service.py
示例19: create
def create(self, req, body, tenant_id):
LOG.debug("req : '%s'\n\n" % req)
LOG.debug("body : '%s'\n\n" % req)
name = body['configuration']['name']
description = body['configuration'].get('description')
values = body['configuration']['values']
msg = _("Creating configuration group on tenant "
"%(tenant_id)s with name: %(cfg_name)s")
LOG.info(msg % {"tenant_id": tenant_id, "cfg_name": name})
datastore_args = body['configuration'].get('datastore', {})
datastore, datastore_version = (
ds_models.get_datastore_version(**datastore_args))
configItems = []
if values:
# validate that the values passed in are permitted by the operator.
ConfigurationsController._validate_configuration(
body['configuration']['values'],
datastore_version,
models.DatastoreConfigurationParameters.load_parameters(
datastore_version.id))
for k, v in values.iteritems():
configItems.append(DBConfigurationParameter(
configuration_key=k,
configuration_value=v))
cfg_group = models.Configuration.create(name, description, tenant_id,
datastore.id,
datastore_version.id)
cfg_group_items = models.Configuration.create_items(cfg_group.id,
values)
view_data = views.DetailedConfigurationView(cfg_group,
cfg_group_items)
return wsgi.Result(view_data.data(), 200)
开发者ID:cp16net,项目名称:trove,代码行数:38,代码来源:service.py
示例20: create
def create(self, req, body, tenant_id):
LOG.debug("Creating a Cluster for Tenant '%s'" % tenant_id)
LOG.info(_("req : '%s'\n\n") % req)
LOG.info(_("body : '%s'\n\n") % body)
context = req.environ[wsgi.CONTEXT_KEY]
name = body['cluster']['name']
datastore_args = body['cluster'].get('datastore', {})
datastore, datastore_version = (
datastore_models.get_datastore_version(**datastore_args))
try:
clusters_enabled = (CONF.get(datastore_version.manager)
.get('cluster_support'))
except NoSuchOptError:
clusters_enabled = False
if not clusters_enabled:
raise exception.ClusterDatastoreNotSupported(
datastore=datastore.name,
datastore_version=datastore_version.name)
nodes = body['cluster']['instances']
instances = []
for node in nodes:
flavor_id = utils.get_id_from_href(node['flavorRef'])
if 'volume' in node:
volume_size = int(node['volume']['size'])
else:
volume_size = None
instances.append({"flavor_id": flavor_id,
"volume_size": volume_size})
cluster = models.Cluster.create(context, name, datastore,
datastore_version, instances)
view = views.load_view(cluster, req=req, load_servers=False)
return wsgi.Result(view.data(), 200)
开发者ID:CMSS-BCRDB,项目名称:RDSV1.0,代码行数:37,代码来源:service.py
注:本文中的trove.datastore.models.get_datastore_version函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论