本文整理汇总了Python中trove.configuration.models.Configuration类的典型用法代码示例。如果您正苦于以下问题:Python Configuration类的具体用法?Python Configuration怎么用?Python Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Configuration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __test_create_configuration
def __test_create_configuration(self):
c = Configuration.create(self.conf_name, self.conf_desc,
self.tanant_id, self.datastore, self.ds_version.id)
self.configuration = c
self.assertTrue(c != None and isinstance(c, DBConfiguration))
defaultConfig = Configuration.create(self.conf_name, self.conf_desc,
self.default_tanant_id, self.datastore, self.ds_version.id)
self.defaultConfiguration = defaultConfig
self.assertTrue(defaultConfig != None and isinstance(defaultConfig, DBConfiguration))
def _error_no_version():
Configuration.create(self.conf_name, self.conf_desc, self.tanant_id, self.datastore, None)
def _error_no_conf_name():
Configuration.create(None, self.conf_desc, self.tanant_id, self.datastore, self.ds_version.id)
def _error_no_tanant_id():
Configuration.create(self.conf_name, self.conf_desc, None, self.datastore, self.ds_version.id)
def _error_provide_error_config_type():
Configuration.create(self.conf_name, self.conf_desc, self.tanant_id, self.datastore, self.ds_version.id, None)
self.assertRaises(Exception, _error_no_version)
self.assertRaises(Exception, _error_no_conf_name)
self.assertRaises(Exception, _error_no_tanant_id)
self.assertRaises(Exception, _error_provide_error_config_type)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:27,代码来源:test_models.py
示例2: unassign_configuration
def unassign_configuration(self):
LOG.debug("Unassigning the configuration from the instance %s.", self.id)
if self.configuration and self.configuration.id:
LOG.debug("Unassigning the configuration id %s.", self.configuration.id)
self.guest.update_overrides({}, remove=True)
# Dynamically reset the configuration values back to their default
# values from the configuration template.
# Reset the values only if the default is available for all of
# them and restart is not required by any.
# Mark the instance with a 'RESTART_REQUIRED' status otherwise.
flavor = self.get_flavor()
default_config = self._render_config_dict(flavor)
current_config = Configuration(self.context, self.configuration.id)
current_overrides = current_config.get_configuration_overrides()
# Check the configuration template has defaults for all modified
# values.
has_defaults_for_all = all(key in default_config.keys() for key in current_overrides.keys())
if not current_config.does_configuration_need_restart() and has_defaults_for_all:
self.guest.apply_overrides({k: v for k, v in default_config.items() if k in current_overrides})
else:
LOG.debug("Could not revert all configuration changes dynamically. " "A restart will be required.")
self.update_db(task_status=InstanceTasks.RESTART_REQUIRED)
else:
LOG.debug("No configuration found on instance. Skipping.")
开发者ID:zjtheone,项目名称:trove,代码行数:26,代码来源:models.py
示例3: __test_admin_update_default_config
def __test_admin_update_default_config(self):
self.defaultConfiguration.name = 'admin_update_default_config_name'
items = Configuration.load_items(self.context, self.defaultConfiguration.id)
items.append(ConfigurationParameter(configuration_id=self.defaultConfiguration.id,
configuration_key='some_key',
configuration_value='some_value',
deleted=False))
self.context.is_admin = True
Configuration.save(self.context, self.defaultConfiguration, items)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:9,代码来源:test_models.py
示例4: test_create_instance_config_from_tempalte
def test_create_instance_config_from_tempalte(self):
self.__test_create_configuration()
old_config_items = Configuration.load_items(self.context, self.configuration.id)
valid_values = {"character_set_connection" : 'utf-8', "innodb_buffer_pool_size" : 1000}
items = Configuration.create_items(self.configuration.id, valid_values)
new_config_items = Configuration.load_items(self.context, self.configuration.id)
instance_config = Configuration.ksc_create_instance_config_from_template(self.context,self.configuration.id)
print instance_config
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:9,代码来源:test_models.py
示例5: _create_resources
def _create_resources():
if cluster_config:
cluster_id = cluster_config.get("id", None)
shard_id = cluster_config.get("shard_id", None)
instance_type = cluster_config.get("instance_type", None)
else:
cluster_id = shard_id = instance_type = None
db_info = DBInstance.create(name=name, flavor_id=flavor_id,
tenant_id=context.tenant,
volume_size=volume_size,
datastore_version_id=
datastore_version.id,
task_status=InstanceTasks.BUILDING,
configuration_id=configuration_id,
slave_of_id=slave_of_id,
cluster_id=cluster_id,
shard_id=shard_id,
type=instance_type)
LOG.debug("Tenant %(tenant)s created new Trove instance %(db)s."
% {'tenant': context.tenant, 'db': db_info.id})
# if a configuration group is associated with an instance,
# generate an overrides dict to pass into the instance creation
# method
config = Configuration(context, configuration_id)
overrides = config.get_configuration_overrides()
service_status = InstanceServiceStatus.create(
instance_id=db_info.id,
status=tr_instance.ServiceStatuses.NEW)
if CONF.trove_dns_support:
dns_client = create_dns_client(context)
hostname = dns_client.determine_hostname(db_info.id)
db_info.hostname = hostname
db_info.save()
root_password = None
if cls.get_root_on_create(
datastore_version.manager) and not backup_id:
root_password = utils.generate_random_password()
task_api.API(context).create_instance(db_info.id, name, flavor,
image_id, databases, users,
datastore_version.manager,
datastore_version.packages,
volume_size, backup_id,
availability_zone,
root_password, nics,
overrides, slave_of_id,
cluster_config)
return SimpleInstance(context, db_info, service_status,
root_password)
开发者ID:ShaguftaMethwani,项目名称:trove,代码行数:56,代码来源:models.py
示例6: tearDown
def tearDown(self):
self.context.is_admin = False
Configuration.delete(self.context, self.configuration)
self.assertTrue(self.configuration.deleted == True)
def _error_not_admin_delete_default_template():
Configuration.delete(self.context, self.defaultConfiguration)
self.assertRaises(Exception, _error_not_admin_delete_default_template)
self.context.is_admin = True
Configuration.delete(self.context, self.defaultConfiguration)
self.assertTrue(self.defaultConfiguration.deleted == True)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:10,代码来源:test_models.py
示例7: test_load
def test_load(self):
self.__test_create_configuration()
conf = Configuration.load(self.context, self.configuration.id)
self.assertTrue(self.configuration.name == conf.name)
defaultConf = Configuration.load(self.context, self.defaultConfiguration.id)
self.assertTrue(self.defaultConfiguration.name == defaultConf.name)
def _error_not_found():
Configuration.load(self.context, "sldkfjasdlkfjsdlkf")
self.assertRaises(ModelNotFoundError, _error_not_found)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:12,代码来源:test_models.py
示例8: test_load_default_templates
def test_load_default_templates(self):
self.tanant_id = CONF.default_template_tenant_id
self.context = TroveContext(tenant = self.tanant_id)
self.__test_create_configuration()
#old_config_items = Configuration.load_items(self.conext, self.configuration.id)
valid_values = {"character_set_connection" : 'utf-8', "innodb_buffer_pool_size" : 1000}
items = Configuration.create_items(self.configuration.id, valid_values)
#new_config_items = Configuration.load_items(self.conext, self.configuration.id)
configs, marker = Configurations.load_default_templates(self.context)
print configs, marker
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:10,代码来源:test_models.py
示例9: assign_configuration
def assign_configuration(self, configuration_id):
try:
configuration = Configuration.load(self.context, configuration_id)
except exception.ModelNotFoundError:
raise exception.NotFound(
message='Configuration group id: %s could not be found'
% configuration_id)
config_ds_v = configuration.datastore_version_id
inst_ds_v = self.db_info.datastore_version_id
if (config_ds_v != inst_ds_v):
raise exception.ConfigurationDatastoreNotMatchInstance(
config_datastore_version=config_ds_v,
instance_datastore_version=inst_ds_v)
overrides = Configuration.get_configuration_overrides(
self.context, configuration.id)
LOG.info(overrides)
self.update_overrides(overrides)
self.update_db(configuration_id=configuration.id)
开发者ID:wrongfan,项目名称:trove,代码行数:22,代码来源:models.py
示例10: test_configuration_parameters
def test_configuration_parameters(self):
self.__test_create_configuration()
self.assertRaises(Exception, self.__test_not_admin_update_default_config)
self.__test_admin_update_default_config()
old_config_items = Configuration.load_items(self.context, self.configuration.id)
self.assertTrue(old_config_items != None and len(old_config_items) == 0)
print old_config_items
valid_values = {"character_set_connection" : 'utf-8', "innodb_buffer_pool_size" : 1000}
items = Configuration.create_items(self.configuration.id, valid_values)
self.assertTrue(items != None and len(items) == len(valid_values), items)
new_config_items = Configuration.load_items(self.context, self.configuration.id)
self.assertTrue(new_config_items != None and len(new_config_items) == 2)
print new_config_items
overrides = Configuration.get_configuration_overrides(self.context, self.configuration.id)
self.assertTrue(valid_values == overrides, overrides)
print valid_values, overrides
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:22,代码来源:test_models.py
示例11: assign_configuration
def assign_configuration(self, configuration_id):
self._validate_can_perform_assign()
try:
configuration = Configuration.load(self.context, configuration_id)
except exception.ModelNotFoundError:
raise exception.NotFound(message="Configuration group id: %s could not be found." % configuration_id)
config_ds_v = configuration.datastore_version_id
inst_ds_v = self.db_info.datastore_version_id
if config_ds_v != inst_ds_v:
raise exception.ConfigurationDatastoreNotMatchInstance(
config_datastore_version=config_ds_v, instance_datastore_version=inst_ds_v
)
config = Configuration(self.context, configuration.id)
LOG.debug("Config config is %s." % config)
self.update_db(configuration_id=configuration.id)
self.update_overrides(config)
开发者ID:rumale,项目名称:trove,代码行数:19,代码来源:models.py
示例12: unassign_configuration
def unassign_configuration(self, flavor, configuration_id):
LOG.debug("Unassigning the configuration from the instance %s" % self.id)
LOG.debug("Unassigning the configuration id %s" % self.configuration.id)
def _find_item(items, item_name):
LOG.debug("items: %s" % items)
LOG.debug("item_name: %s" % item_name)
# find the item in the list
for i in items:
if i[0] == item_name:
return i
def _convert_value(value):
# split the value and the size e.g. 512M=['512','M']
pattern = re.compile("(\d+)(\w+)")
split = pattern.findall(value)
if len(split) < 2:
return value
digits, size = split
conversions = {"K": 1024, "M": 1024 ** 2, "G": 1024 ** 3}
return str(int(digits) * conversions[size])
default_config = self._render_config_dict(flavor)
args = {"ds_manager": self.ds_version.manager, "config": default_config}
LOG.debug("default %(ds_manager)s section: %(config)s" % args)
LOG.debug("self.configuration: %s" % self.configuration.__dict__)
overrides = {}
config_items = Configuration.load_items(self.context, configuration_id)
for item in config_items:
LOG.debug("finding item(%s)" % item.__dict__)
try:
key, val = _find_item(default_config, item.configuration_key)
except TypeError:
val = None
restart_required = inst_models.InstanceTasks.RESTART_REQUIRED
self.update_db(task_status=restart_required)
if val:
overrides[item.configuration_key] = _convert_value(val)
LOG.debug("setting the default variables in dict: %s" % overrides)
self.update_overrides(overrides, remove=True)
self.update_db(configuration_id=None)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:42,代码来源:models.py
示例13: _error_not_admin_delete_default_template
def _error_not_admin_delete_default_template():
Configuration.delete(self.context, self.defaultConfiguration)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:2,代码来源:test_models.py
示例14: _error_no_version
def _error_no_version():
Configuration.create(self.conf_name, self.conf_desc, self.tanant_id, self.datastore, None)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:2,代码来源:test_models.py
示例15: _error_no_tanant_id
def _error_no_tanant_id():
Configuration.create(self.conf_name, self.conf_desc, None, self.datastore, self.ds_version.id)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:2,代码来源:test_models.py
示例16: __test_not_admin_update_default_config
def __test_not_admin_update_default_config(self):
self.defaultConfiguration.name = 'update_default_config_name'
old_config_items = Configuration.load_items(self.context, self.defaultConfiguration.id)
Configuration.save(self.context, self.defaultConfiguration, old_config_items)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:4,代码来源:test_models.py
示例17: _error_provide_error_config_type
def _error_provide_error_config_type():
Configuration.create(self.conf_name, self.conf_desc, self.tanant_id, self.datastore, self.ds_version.id, None)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:2,代码来源:test_models.py
示例18: configuration
def configuration(self):
if self.db_info.configuration_id is not None:
return Configuration.load(self.context,
self.db_info.configuration_id)
开发者ID:cretta,项目名称:trove,代码行数:4,代码来源:models.py
示例19: _create_resources
def _create_resources():
if cluster_config:
cluster_id = cluster_config.get("id", None)
shard_id = cluster_config.get("shard_id", None)
instance_type = cluster_config.get("instance_type", None)
else:
cluster_id = shard_id = instance_type = None
ids = []
names = []
root_passwords = []
root_password = None
for instance_index in range(0, instance_count):
db_info = DBInstance.create(
name=name, flavor_id=flavor_id, tenant_id=context.tenant,
volume_size=volume_size,
datastore_version_id=datastore_version.id,
task_status=InstanceTasks.BUILDING,
configuration_id=configuration_id,
slave_of_id=slave_of_id, cluster_id=cluster_id,
shard_id=shard_id, type=instance_type)
LOG.debug("Tenant %(tenant)s created new Trove instance "
"%(db)s.",
{'tenant': context.tenant, 'db': db_info.id})
instance_id = db_info.id
instance_name = name
ids.append(instance_id)
names.append(instance_name)
root_passwords.append(None)
# change the name to be name + replica_number if more than one
if multi_replica:
replica_number = instance_index + 1
names[instance_index] += '-' + str(replica_number)
setattr(db_info, 'name', names[instance_index])
db_info.save()
# if a configuration group is associated with an instance,
# generate an overrides dict to pass into the instance creation
# method
config = Configuration(context, configuration_id)
overrides = config.get_configuration_overrides()
service_status = InstanceServiceStatus.create(
instance_id=instance_id,
status=tr_instance.ServiceStatuses.NEW)
if CONF.trove_dns_support:
dns_client = create_dns_client(context)
hostname = dns_client.determine_hostname(instance_id)
db_info.hostname = hostname
db_info.save()
if cls.get_root_on_create(
datastore_version.manager) and not backup_id:
root_password = utils.generate_random_password()
root_passwords[instance_index] = root_password
if instance_count > 1:
instance_id = ids
instance_name = names
root_password = root_passwords
task_api.API(context).create_instance(
instance_id, instance_name, flavor, image_id, databases, users,
datastore_version.manager, datastore_version.packages,
volume_size, backup_id, availability_zone, root_password,
nics, overrides, slave_of_id, cluster_config)
return SimpleInstance(context, db_info, service_status,
root_password)
开发者ID:cretta,项目名称:trove,代码行数:71,代码来源:models.py
示例20: _error_not_found
def _error_not_found():
Configuration.load(self.context, "sldkfjasdlkfjsdlkf")
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:2,代码来源:test_models.py
注:本文中的trove.configuration.models.Configuration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论