本文整理汇总了Python中trove.common.remote.create_guest_client函数的典型用法代码示例。如果您正苦于以下问题:Python create_guest_client函数的具体用法?Python create_guest_client怎么用?Python create_guest_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_guest_client函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: guest_log_list
def guest_log_list(self, req, tenant_id, id):
"""Return all information about all logs for an instance."""
LOG.debug("Listing logs for tenant %s" % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
client = create_guest_client(context, id)
guest_log_list = client.guest_log_list()
return wsgi.Result({'logs': guest_log_list}, 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:7,代码来源:service.py
示例2: update_attributes
def update_attributes(cls, context, instance_id, username, hostname,
user_attrs):
load_and_verify(context, instance_id)
client = create_guest_client(context, instance_id)
user_changed = user_attrs.get('name')
host_changed = user_attrs.get('host')
validate = guest_models.MySQLUser()
if host_changed:
validate.host = host_changed
if user_changed:
validate.name = user_changed
user = user_changed or username
host = host_changed or hostname
userhost = "%[email protected]%s" % (user, host)
if user_changed or host_changed:
existing_users, _nadda = Users.load_with_client(
client,
limit=1,
marker=userhost,
include_marker=True)
if (len(existing_users) > 0 and
existing_users[0].name == user and
existing_users[0].host == host):
raise exception.UserAlreadyExists(name=user,
host=host)
client.update_attributes(username, hostname, user_attrs)
开发者ID:cretta,项目名称:trove,代码行数:29,代码来源:models.py
示例3: create
def create(cls, context, instance_id, user, root_password, cluster_instances_list=None):
load_and_verify(context, instance_id)
if root_password:
root = create_guest_client(context, instance_id).enable_root_with_password(root_password)
else:
root = create_guest_client(context, instance_id).enable_root()
root_user = guest_models.RootUser()
root_user.deserialize(root)
# if cluster_instances_list none, then root create is called for
# single instance, adding an RootHistory entry for the instance_id
if cluster_instances_list is None:
RootHistory.create(context, instance_id, user)
return root_user
开发者ID:magictour,项目名称:trove,代码行数:16,代码来源:models.py
示例4: create
def create(cls, context, instance_id, user):
load_and_verify(context, instance_id)
root = create_guest_client(context, instance_id).enable_root()
root_user = guest_models.RootUser()
root_user.deserialize(root)
RootHistory.create(context, instance_id, user)
return root_user
开发者ID:cretta,项目名称:trove,代码行数:7,代码来源:models.py
示例5: load_guest_info
def load_guest_info(instance, context, id):
if instance.status not in AGENT_INVALID_STATUSES:
guest = create_guest_client(context, id)
try:
instance.volume_used = guest.get_volume_info()['used']
except Exception as e:
LOG.error(e)
return instance
开发者ID:pabelanger,项目名称:trove,代码行数:8,代码来源:models.py
示例6: load_via_context
def load_via_context(cls, context, instance_id):
"""Creates guest and fetches pagination arguments from the context."""
load_and_verify(context, instance_id)
limit = utils.pagination_limit(context.limit, cls.DEFAULT_LIMIT)
client = create_guest_client(context, instance_id)
# The REST API standard dictates that we *NEVER* include the marker.
return cls.load_with_client(client=client, limit=limit,
marker=context.marker, include_marker=False)
开发者ID:Hopebaytech,项目名称:trove,代码行数:8,代码来源:models.py
示例7: access
def access(cls, context, instance_id, username, hostname):
load_and_verify(context, instance_id)
client = create_guest_client(context, instance_id)
databases = client.list_access(username, hostname)
dbs = []
for db in databases:
dbs.append(Schema(name=db["_name"], collate=db["_collate"], character_set=db["_character_set"]))
return UserAccess(dbs)
开发者ID:neetugrewal,项目名称:trove,代码行数:8,代码来源:models.py
示例8: change_password
def change_password(cls, context, instance_id, users):
load_and_verify(context, instance_id)
client = create_guest_client(context, instance_id)
change_users = []
for user in users:
change_user = {"name": user.name, "host": user.host, "password": user.password}
change_users.append(change_user)
client.change_passwords(change_users)
开发者ID:neetugrewal,项目名称:trove,代码行数:8,代码来源:models.py
示例9: check_rpl_delay
def check_rpl_delay(slave_id):
LOG.info("\n\n\n============= check rpl delay ====================== %s" % slave_id)
guestagent_api = create_guest_client(get_context(),slave_id)
_obj = guestagent_api.ksc_rpl_delay()
if int(_obj) <=1:
LOG.info('master-slave rpl ok')
else:
msg = 'master-slave rpl occur delay'
raise Exception(msg)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:9,代码来源:utils.py
示例10: create
def create(cls, context, instance_id, schemas):
load_and_verify(context, instance_id)
client = create_guest_client(context, instance_id)
for schema in schemas:
schema_name = schema["_name"]
existing_schema, _nadda = Schemas.load_with_client(client, limit=1, marker=schema_name, include_marker=True)
if len(existing_schema) > 0 and str(existing_schema[0].name) == str(schema_name):
raise exception.DatabaseAlreadyExists(name=schema_name)
return client.create_database(schemas)
开发者ID:neetugrewal,项目名称:trove,代码行数:9,代码来源:models.py
示例11: guest_log_list
def guest_log_list(self, req, tenant_id, id):
"""Return all information about all logs for an instance."""
LOG.debug("Listing logs for tenant %s" % tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)
client = create_guest_client(context, id)
guest_log_list = client.guest_log_list()
return wsgi.Result({'logs': guest_log_list}, 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:10,代码来源:service.py
示例12: change_password
def change_password(cls, context, instance_id, users):
load_and_verify(context, instance_id)
client = create_guest_client(context, instance_id)
change_users = []
for user in users:
change_user = {'name': user.name,
'host': user.host,
'password': user.password,
}
change_users.append(change_user)
client.change_passwords(change_users)
开发者ID:cretta,项目名称:trove,代码行数:11,代码来源:models.py
示例13: load
def load(cls, context, instance_id, username, hostname):
load_and_verify(context, instance_id)
validate = guest_models.MySQLUser()
validate.name = username
validate.host = hostname
client = create_guest_client(context, instance_id)
found_user = client.get_user(username=username, hostname=hostname)
if not found_user:
return None
database_names = [{"name": db["_name"]} for db in found_user["_databases"]]
return cls(found_user["_name"], found_user["_host"], found_user["_password"], database_names)
开发者ID:neetugrewal,项目名称:trove,代码行数:11,代码来源:models.py
示例14: check_rpl_consist
def check_rpl_consist(master_id,slave_ids,master_ip,slave_ips):
global is_check_rpl_consit
if is_check_rpl_consit:
LOG.info("\n\n\n============= check rpl consistense ======================")
username = "rpltest"
password = "kingsoft"
guestagent_api = create_guest_client(get_context(),master_id)
guestagent_api.admin_create_replica_checking_user(chkUser = username, chkPsw = password)
for _id in slave_ids:
guestagent_api = create_guest_client(get_context(),_id)
guestagent_api.admin_create_replica_checking_user(chkUser = username, chkPsw = password)
#print _obj
mysqlip = "mysql://%s:%[email protected]%s:3306/"
rplcheck = ReplicaChecker(
mysqlip % (username,password,master_ip),
[mysqlip % (username,password,ip) for ip in slave_ips])
_ret_dict = rplcheck.replica_consistence_check_by_master_slave()
for k,v in _ret_dict.iteritems():
LOG.info("%s %s" % (k,v))
for k,v in _ret_dict.iteritems():
if v>0:
raise Exception("replica consistence find error on %s" % k)
开发者ID:zhujzhuo,项目名称:trove-1.0.10.4,代码行数:23,代码来源:utils.py
示例15: module_remove
def module_remove(self, req, tenant_id, id, module_id):
"""Remove module from an instance."""
context = req.environ[wsgi.CONTEXT_KEY]
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)
module = module_models.Module.load(context, module_id)
module_info = module_views.DetailedModuleView(module).data()
client = create_guest_client(context, id)
client.module_remove(module_info)
instance_module = module_models.InstanceModule.load(
context, instance_id=id, module_id=module_id)
if instance_module:
module_models.InstanceModule.delete(context, instance_module)
return wsgi.Result(None, 200)
开发者ID:Hopebaytech,项目名称:trove,代码行数:15,代码来源:service.py
示例16: update_all
def update_all(self, context):
num_i = len(self.instances)
LOG.debug("Host %s has %s instances to update" % (self.name, num_i))
failed_instances = []
for instance in self.instances:
client = create_guest_client(context, instance['id'])
try:
client.update_guest()
except exception.TroveError as re:
LOG.error(re)
LOG.error("Unable to update instance: %s" % instance['id'])
failed_instances.append(instance['id'])
if len(failed_instances) > 0:
msg = "Failed to update instances: %s" % failed_instances
raise exception.UpdateGuestError(msg)
开发者ID:CiscoSystems,项目名称:openstack-trove,代码行数:15,代码来源:models.py
示例17: guest_log_action
def guest_log_action(self, req, body, tenant_id, id):
"""Processes a guest log."""
LOG.info(_("Processing log for tenant %s"), tenant_id)
context = req.environ[wsgi.CONTEXT_KEY]
log_name = body['name']
enable = body.get('enable', None)
disable = body.get('disable', None)
publish = body.get('publish', None)
discard = body.get('discard', None)
if enable and disable:
raise exception.BadRequest(_("Cannot enable and disable log."))
client = create_guest_client(context, id)
guest_log = client.guest_log_action(log_name, enable, disable,
publish, discard)
return wsgi.Result({'log': guest_log}, 200)
开发者ID:paramtech,项目名称:tesora-trove,代码行数:15,代码来源:service.py
示例18: module_apply
def module_apply(self, req, body, tenant_id, id):
"""Apply modules to an instance."""
context = req.environ[wsgi.CONTEXT_KEY]
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)
self.authorize_instance_action(context, 'module_apply', instance)
module_ids = [mod['id'] for mod in body.get('modules', [])]
modules = module_models.Modules.load_by_ids(context, module_ids)
models.validate_modules_for_apply(
modules, instance.datastore.id, instance.datastore_version.id)
module_list = module_views.get_module_list(modules)
client = create_guest_client(context, id)
result_list = client.module_apply(module_list)
models.Instance.add_instance_modules(context, id, modules)
return wsgi.Result({'modules': result_list}, 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:16,代码来源:service.py
示例19: module_remove
def module_remove(self, req, tenant_id, id, module_id):
"""Remove module from an instance."""
context = req.environ[wsgi.CONTEXT_KEY]
instance = models.Instance.load(context, id)
if not instance:
raise exception.NotFound(uuid=id)
self.authorize_instance_action(context, 'module_remove', instance)
module = module_models.Module.load(context, module_id)
module_info = module_views.DetailedModuleView(module).data()
client = create_guest_client(context, id)
client.module_remove(module_info)
instance_modules = module_models.InstanceModules.load_all(
context, instance_id=id, module_id=module_id)
for instance_module in instance_modules:
module_models.InstanceModule.delete(context, instance_module)
LOG.debug("Deleted IM record %s (instance %s, module %s)." %
(instance_module.id, id, module_id))
return wsgi.Result(None, 200)
开发者ID:Tesora,项目名称:tesora-trove,代码行数:18,代码来源:service.py
示例20: load
def load(cls, context, instance_id, username, hostname, root_user=False):
load_and_verify(context, instance_id)
if root_user:
validate = guest_models.RootUser()
else:
validate = guest_models.MySQLUser()
validate.name = username
validate.host = hostname
client = create_guest_client(context, instance_id)
found_user = client.get_user(username=username, hostname=hostname)
if not found_user:
return None
database_names = [{'name': db['_name']}
for db in found_user['_databases']]
return cls(found_user['_name'],
found_user['_host'],
found_user['_password'],
database_names)
开发者ID:Hopebaytech,项目名称:trove,代码行数:18,代码来源:models.py
注:本文中的trove.common.remote.create_guest_client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论