本文整理汇总了Python中troveclient.base.getid函数的典型用法代码示例。如果您正苦于以下问题:Python getid函数的具体用法?Python getid怎么用?Python getid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: module_remove
def module_remove(self, instance, module):
"""Remove a module from an instance.
"""
url = "/instances/%s/modules/%s" % (base.getid(instance),
base.getid(module))
resp, body = self.api.client.delete(url)
common.check_for_exceptions(resp, body, url)
示例2: test_getid
def test_getid(self):
obj = "test"
r = base.getid(obj)
self.assertEqual(obj, r)
test_id = "test_id"
obj = mock.Mock()
obj.id = test_id
r = base.getid(obj)
self.assertEqual(test_id, r)
示例3: modify
def modify(self, instance, configuration=None):
body = {
"instance": {
}
}
if configuration is not None:
body["instance"]["configuration"] = base.getid(configuration)
url = "/instances/%s" % base.getid(instance)
resp, body = self.api.client.put(url, body=body)
common.check_for_exceptions(resp, body, url)
示例4: create
def create(self, name, flavor_id, volume=None, databases=None, users=None,
restorePoint=None, availability_zone=None, datastore=None,
datastore_version=None, nics=None, configuration=None,
replica_of=None, slave_of=None, replica_count=None,
modules=None, locality=None):
"""Create (boot) a new instance."""
body = {"instance": {
"name": name,
"flavorRef": flavor_id
}}
datastore_obj = {}
if volume:
body["instance"]["volume"] = volume
if databases:
body["instance"]["databases"] = databases
if users:
body["instance"]["users"] = users
if restorePoint:
body["instance"]["restorePoint"] = restorePoint
if availability_zone:
body["instance"]["availability_zone"] = availability_zone
if datastore:
datastore_obj["type"] = datastore
if datastore_version:
datastore_obj["version"] = datastore_version
if datastore_obj:
body["instance"]["datastore"] = datastore_obj
if nics:
body["instance"]["nics"] = nics
if configuration:
body["instance"]["configuration"] = base.getid(configuration)
if replica_of or slave_of:
if slave_of:
warnings.warn(_LW("The 'slave_of' argument is deprecated in "
"favor of 'replica_of' and will be removed "
"after the Trove liberty series is end of "
"life."),
category=DeprecationWarning)
body["instance"]["replica_of"] = base.getid(replica_of) or slave_of
if replica_count:
body["instance"]["replica_count"] = replica_count
if modules:
body["instance"]["modules"] = self._get_module_list(modules)
if locality:
body["instance"]["locality"] = locality
return self._create("/instances", body, "instance")
示例5: schedule_create
def schedule_create(self, instance, pattern, name,
description=None, incremental=False,
mistral_client=None):
"""Create a new schedule to backup the given instance.
:param instance: instance to backup.
:param: pattern: cron pattern for schedule.
:param name: name for backup.
:param description: (optional).
:param incremental: flag for incremental backup (optional).
:returns: :class:`Backups`
"""
if not mistral_client:
mistral_client = self._get_mistral_client()
inst_id = base.getid(instance)
cron_name = str(uuid.uuid4())
wf_input = {"instance": inst_id,
"name": name,
"description": description,
"incremental": incremental
}
cron_trigger = mistral_client.cron_triggers.create(
cron_name, self.backup_create_workflow, pattern=pattern,
workflow_input=wf_input)
return self._build_schedule(cron_trigger, wf_input)
示例6: backups
def backups(self, instance):
"""
Get the list of backups for a specific instance.
:rtype: list of :class:`Backups`.
"""
return self._list("/instances/%s/backups" % base.getid(instance), "backups")
示例7: change_passwords
def change_passwords(self, instance, users):
"""Change the password for one or more users."""
instance_id = base.getid(instance)
user_dict = {"users": users}
url = "/instances/%s/users" % instance_id
resp, body = self.api.client.put(url, body=user_dict)
common.check_for_exceptions(resp, body, url)
示例8: get
def get(self, flavor):
"""Get a specific flavor.
:rtype: :class:`Flavor`
"""
return self._get("/flavors/%s" % base.getid(flavor),
"flavor")
示例9: backups
def backups(self, instance, limit=None, marker=None):
"""Get the list of backups for a specific instance.
:rtype: list of :class:`Backups`.
"""
url = "/instances/%s/backups" % base.getid(instance)
return self._paginated(url, "backups", limit, marker)
示例10: get
def get(self, configuration):
"""Get a specific configuration.
:rtype: :class:`Configurations`
"""
return self._get("/configurations/%s" % base.getid(configuration),
"configuration")
示例11: get
def get(self, datastore):
"""Get a specific datastore.
:rtype: :class:`Datastore`
"""
return self._get("/datastores/%s" % base.getid(datastore),
"datastore")
示例12: get
def get(self, backup):
"""Get a specific backup.
:rtype: :class:`Backups`
"""
return self._get("/backups/%s" % base.getid(backup),
"backup")
示例13: get
def get(self, cluster):
"""Get a specific cluster.
:rtype: :class:`Cluster`
"""
return self._get("/clusters/%s" % base.getid(cluster),
"cluster")
示例14: create
def create(self, name, instance, description=None, parent_id=None,
backup=None, incremental=False):
"""Create a new backup from the given instance.
:param name: name for backup.
:param instance: instance to backup.
:param description: (optional).
:param parent_id: base for incremental backup (optional).
:param incremental: flag to indicate incremental backup based on
last backup
:returns: :class:`Backups`
"""
body = {
"backup": {
"name": name,
"incremental": int(incremental)
}
}
if instance:
body['backup']['instance'] = base.getid(instance)
if backup:
body["backup"]['backup'] = backup
if description:
body['backup']['description'] = description
if parent_id:
body['backup']['parent_id'] = parent_id
return self._create("/backups", body, "backup")
示例15: list
def list(self, limit=None, marker=None, datastore=None):
"""Get a list of all modules."""
query_strings = None
if datastore:
query_strings = {"datastore": base.getid(datastore)}
return self._paginated(
"/modules", "modules", limit, marker, query_strings=query_strings)