本文整理汇总了Python中nova.cells.utils.split_cell_and_item函数的典型用法代码示例。如果您正苦于以下问题:Python split_cell_and_item函数的具体用法?Python split_cell_and_item怎么用?Python split_cell_and_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split_cell_and_item函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: service_get_all
def service_get_all(self, context, filters=None, set_zones=False):
if filters is None:
filters = {}
if "availability_zone" in filters:
zone_filter = filters.pop("availability_zone")
set_zones = True
else:
zone_filter = None
services = self.cells_rpcapi.service_get_all(context, filters=filters)
if set_zones:
# TODO(sbauza): set_availability_zones returns flat dicts,
# we should rather modify the RPC API to amend service_get_all by
# adding a set_zones argument
services = availability_zones.set_availability_zones(context, services)
if zone_filter is not None:
services = [s for s in services if s["availability_zone"] == zone_filter]
# NOTE(sbauza): As services is a list of flat dicts, we need to
# rehydrate the corresponding ServiceProxy objects
cell_paths = []
for service in services:
cell_path, id = cells_utils.split_cell_and_item(service["id"])
cell_path, host = cells_utils.split_cell_and_item(service["host"])
service["id"] = id
service["host"] = host
cell_paths.append(cell_path)
services = obj_base.obj_make_list(context, objects.ServiceList(), objects.Service, services)
services = [cells_utils.ServiceProxy(s, c) for s, c in zip(services, cell_paths)]
return services
开发者ID:cyx1231st,项目名称:nova,代码行数:30,代码来源:cells_api.py
示例2: proxy_rpc_to_manager
def proxy_rpc_to_manager(self, ctxt, topic, rpc_message, call, timeout):
"""Proxy an RPC message as-is to a manager."""
compute_topic = CONF.compute_topic
cell_and_host = topic[len(compute_topic) + 1 :]
cell_name, host_name = cells_utils.split_cell_and_item(cell_and_host)
response = self.msg_runner.proxy_rpc_to_manager(ctxt, cell_name, host_name, topic, rpc_message, call, timeout)
return response.value_or_raise()
开发者ID:mathslinux,项目名称:nova,代码行数:7,代码来源:manager.py
示例3: task_log_get_all
def task_log_get_all(self, ctxt, task_name, period_beginning,
period_ending, host=None, state=None):
"""Get task logs from the DB from all cells or a particular
cell.
If 'host' is not None, host will be of the format '[email protected]',
with '@host' being optional. The query will be directed to the
appropriate cell and return all task logs, or task logs matching
the host if specified.
'state' also may be None. If it's not, filter by the state as well.
"""
if host is None:
cell_name = None
else:
cell_name, host = cells_utils.split_cell_and_item(host)
# If no cell name was given, assume that the host name is the
# cell_name and that the target is all hosts
if cell_name is None:
cell_name, host = host, cell_name
responses = self.msg_runner.task_log_get_all(ctxt, cell_name,
task_name, period_beginning, period_ending,
host=host, state=state)
# 1 response per cell. Each response is a list of task log
# entries.
ret_task_logs = []
for response in responses:
task_logs = response.value_or_raise()
for task_log in task_logs:
cells_utils.add_cell_to_task_log(task_log,
response.cell_name)
ret_task_logs.append(task_log)
return ret_task_logs
开发者ID:MrDarcys,项目名称:nova,代码行数:33,代码来源:manager.py
示例4: service_get_all
def service_get_all(self, context, filters=None, set_zones=False):
if filters is None:
filters = {}
if "availability_zone" in filters:
zone_filter = filters.pop("availability_zone")
set_zones = True
else:
zone_filter = None
services = self.cells_rpcapi.service_get_all(context, filters=filters)
if set_zones:
services = availability_zones.set_availability_zones(context, services)
if zone_filter is not None:
services = [s for s in services if s["availability_zone"] == zone_filter]
# NOTE(johannes): Cells adds the cell path as a prefix to the id
# to uniquely identify the service amongst all cells. Unfortunately
# the object model makes the id an integer. Use a proxy here to
# work around this particular problem.
# Split out the cell path first
cell_paths = []
for service in services:
cell_path, id = cells_utils.split_cell_and_item(service["id"])
service["id"] = id
cell_paths.append(cell_path)
# NOTE(danms): Currently cells does not support objects as
# return values, so just convert the db-formatted service objects
# to new-world objects here
services = obj_base.obj_make_list(context, objects.ServiceList(), objects.Service, services)
# Now wrap it in the proxy with the original cell_path
services = [ServiceProxy(s, c) for s, c in zip(services, cell_paths)]
return services
开发者ID:humble00,项目名称:nova,代码行数:33,代码来源:cells_api.py
示例5: _validate_id
def _validate_id(req, hypervisor_id):
"""Validates that the id is a uuid for microversions that require it.
:param req: The HTTP request object which contains the requested
microversion information.
:param hypervisor_id: The provided hypervisor id.
:raises: webob.exc.HTTPBadRequest if the requested microversion is
greater than or equal to 2.53 and the id is not a uuid.
:raises: webob.exc.HTTPNotFound if the requested microversion is
less than 2.53 and the id is not an integer.
"""
expect_uuid = api_version_request.is_supported(
req, min_version=UUID_FOR_ID_MIN_VERSION)
if expect_uuid:
if not uuidutils.is_uuid_like(hypervisor_id):
msg = _('Invalid uuid %s') % hypervisor_id
raise webob.exc.HTTPBadRequest(explanation=msg)
else:
# This API is supported for cells v1 and as such the id can be
# a cell v1 delimited string, so we have to parse it first.
if cells_utils.CELL_ITEM_SEP in str(hypervisor_id):
hypervisor_id = cells_utils.split_cell_and_item(
hypervisor_id)[1]
try:
utils.validate_integer(hypervisor_id, 'id')
except exception.InvalidInput:
msg = (_("Hypervisor with ID '%s' could not be found.") %
hypervisor_id)
raise webob.exc.HTTPNotFound(explanation=msg)
开发者ID:Juniper,项目名称:nova,代码行数:29,代码来源:hypervisors.py
示例6: compute_node_get
def compute_node_get(self, ctxt, compute_id):
"""Get a compute node by ID in a specific cell."""
cell_name, compute_id = cells_utils.split_cell_and_item(compute_id)
response = self.msg_runner.compute_node_get(ctxt, cell_name, compute_id)
node = response.value_or_raise()
node = cells_utils.add_cell_to_compute_node(node, cell_name)
return node
开发者ID:mathslinux,项目名称:nova,代码行数:7,代码来源:manager.py
示例7: service_get_by_compute_host
def service_get_by_compute_host(self, ctxt, host_name):
"""Return a service entry for a compute host in a certain cell."""
cell_name, host_name = cells_utils.split_cell_and_item(host_name)
response = self.msg_runner.service_get_by_compute_host(ctxt, cell_name, host_name)
service = response.value_or_raise()
service = cells_utils.add_cell_to_service(service, response.cell_name)
return service
开发者ID:mathslinux,项目名称:nova,代码行数:7,代码来源:manager.py
示例8: get_host_uptime
def get_host_uptime(self, ctxt, host_name):
"""Return host uptime for a compute host in a certain cell
:param host_name: fully qualified hostname. It should be in format of
[email protected]_id
"""
cell_name, host_name = cells_utils.split_cell_and_item(host_name)
response = self.msg_runner.get_host_uptime(ctxt, cell_name, host_name)
return response.value_or_raise()
开发者ID:mathslinux,项目名称:nova,代码行数:9,代码来源:manager.py
示例9: service_get_all
def service_get_all(self, context, filters=None, set_zones=False,
all_cells=False):
"""Get all services.
Note that this is the cellsv1 variant, which means we ignore the
"all_cells" parameter.
"""
if filters is None:
filters = {}
if 'availability_zone' in filters:
zone_filter = filters.pop('availability_zone')
set_zones = True
else:
zone_filter = None
services = self.cells_rpcapi.service_get_all(context,
filters=filters)
if set_zones:
# TODO(sbauza): set_availability_zones returns flat dicts,
# we should rather modify the RPC API to amend service_get_all by
# adding a set_zones argument
services = availability_zones.set_availability_zones(context,
services)
if zone_filter is not None:
services = [s for s in services
if s['availability_zone'] == zone_filter]
# NOTE(sbauza): As services is a list of flat dicts, we need to
# rehydrate the corresponding ServiceProxy objects
cell_paths = []
for service in services:
cell_path, id = cells_utils.split_cell_and_item(service['id'])
cell_path, host = cells_utils.split_cell_and_item(
service['host'])
service['id'] = id
service['host'] = host
cell_paths.append(cell_path)
services = obj_base.obj_make_list(context,
objects.ServiceList(),
objects.Service,
services)
services = [cells_utils.ServiceProxy(s, c)
for s, c in zip(services, cell_paths)]
return services
开发者ID:andymcc,项目名称:nova,代码行数:44,代码来源:cells_api.py
示例10: test_split_cell_and_item
def test_split_cell_and_item(self):
path = 'australia', 'queensland', 'gold_coast'
cell = cells_utils._PATH_CELL_SEP.join(path)
item = 'host_5'
together = cells_utils.cell_with_item(cell, item)
self.assertEqual(cells_utils._CELL_ITEM_SEP.join([cell, item]),
together)
# Test normal usage
result_cell, result_item = cells_utils.split_cell_and_item(together)
self.assertEqual(cell, result_cell)
self.assertEqual(item, result_item)
# Test with no cell
cell = None
together = cells_utils.cell_with_item(cell, item)
self.assertEqual(item, together)
result_cell, result_item = cells_utils.split_cell_and_item(together)
self.assertEqual(cell, result_cell)
self.assertEqual(item, result_item)
开发者ID:DavidYan,项目名称:nova,代码行数:20,代码来源:test_cells_utils.py
示例11: instance_get_all_by_host
def instance_get_all_by_host(self, context, host_name):
"""Get all instances by host. Host might have a cell prepended
to it, so we'll need to strip it out. We don't need to proxy
this call to cells, as we have instance information here in
the API cell.
"""
cell_name, host_name = cells_utils.split_cell_and_item(host_name)
instances = super(HostAPI, self).instance_get_all_by_host(context, host_name)
if cell_name:
instances = [i for i in instances if i["cell_name"] == cell_name]
return instances
开发者ID:cyx1231st,项目名称:nova,代码行数:11,代码来源:cells_api.py
示例12: service_get_by_compute_host
def service_get_by_compute_host(self, context, host_name):
try:
db_service = self.cells_rpcapi.service_get_by_compute_host(context,
host_name)
except exception.CellRoutingInconsistency:
raise exception.ComputeHostNotFound(host=host_name)
# NOTE(danms): Currently cells does not support objects as
# return values, so just convert the db-formatted service objects
# to new-world objects here
# NOTE(dheeraj): Use ServiceProxy here too. See johannes'
# note on service_get_all
if db_service:
# NOTE(alaski): Creation of the Service object involves creating
# a ComputeNode object in this case. This will fail because with
# cells the 'id' is a string of the format '[email protected]' but
# the object expects the 'id' to be an int.
if 'compute_node' in db_service:
# NOTE(alaski): compute_node is a list that should have one
# item in it, except in the case of Ironic. But the Service
# object only uses the first compute_node for its relationship
# so we only need to pull the first one here.
db_compute = db_service['compute_node'][0]
comp_cell_path, comp_id = cells_utils.split_cell_and_item(
db_compute['id'])
db_compute['id'] = comp_id
cell_path, _id = cells_utils.split_cell_and_item(db_service['id'])
db_service['id'] = _id
ser_obj = objects.Service._from_db_object(context,
objects.Service(),
db_service)
compute_proxy = None
if 'compute_node' in db_service:
compute_proxy = ComputeNodeProxy(ser_obj.compute_node,
comp_cell_path)
return ServiceProxy(ser_obj, cell_path, compute_node=compute_proxy)
开发者ID:dtroyer,项目名称:nova,代码行数:39,代码来源:cells_api.py
示例13: service_update
def service_update(self, ctxt, host_name, binary, params_to_update):
"""Used to enable/disable a service. For compute services, setting to
disabled stops new builds arriving on that host.
:param host_name: the name of the host machine that the service is
running
:param binary: The name of the executable that the service runs as
:param params_to_update: eg. {'disabled': True}
:returns: the service reference
"""
cell_name, host_name = cells_utils.split_cell_and_item(host_name)
response = self.msg_runner.service_update(ctxt, cell_name, host_name, binary, params_to_update)
service = response.value_or_raise()
service = cells_utils.add_cell_to_service(service, response.cell_name)
return service
开发者ID:mathslinux,项目名称:nova,代码行数:15,代码来源:manager.py
示例14: service_get_by_compute_host
def service_get_by_compute_host(self, context, host_name):
db_service = self.cells_rpcapi.service_get_by_compute_host(context,
host_name)
# NOTE(danms): Currently cells does not support objects as
# return values, so just convert the db-formatted service objects
# to new-world objects here
# NOTE(dheeraj): Use ServiceProxy here too. See johannes'
# note on service_get_all
if db_service:
cell_path, _id = cells_utils.split_cell_and_item(db_service['id'])
db_service['id'] = _id
ser_obj = objects.Service._from_db_object(context,
objects.Service(),
db_service)
return ServiceProxy(ser_obj, cell_path)
开发者ID:EdLeafe,项目名称:nova,代码行数:16,代码来源:cells_api.py
示例15: service_update
def service_update(self, context, host_name, binary, params_to_update):
"""Used to enable/disable a service. For compute services, setting to
disabled stops new builds arriving on that host.
:param host_name: the name of the host machine that the service is
running
:param binary: The name of the executable that the service runs as
:param params_to_update: eg. {'disabled': True}
"""
db_service = self.cells_rpcapi.service_update(
context, host_name, binary, params_to_update)
# NOTE(danms): Currently cells does not support objects as
# return values, so just convert the db-formatted service objects
# to new-world objects here
# NOTE(dheeraj): Use ServiceProxy here too. See johannes'
# note on service_get_all
if db_service:
cell_path, _id = cells_utils.split_cell_and_item(db_service['id'])
db_service['id'] = _id
ser_obj = objects.Service._from_db_object(context,
objects.Service(),
db_service)
return ServiceProxy(ser_obj, cell_path)
开发者ID:EdLeafe,项目名称:nova,代码行数:24,代码来源:cells_api.py
示例16: service_delete
def service_delete(self, ctxt, cell_service_id):
"""Deletes the specified service."""
cell_name, service_id = cells_utils.split_cell_and_item(
cell_service_id)
self.msg_runner.service_delete(ctxt, cell_name, service_id)
开发者ID:MrDarcys,项目名称:nova,代码行数:5,代码来源:manager.py
示例17: evacuate
def evacuate(self, context, instance, host, *args, **kwargs):
"""Evacuate the given instance with the provided attributes."""
if host:
cell_path, host = cells_utils.split_cell_and_item(host)
self._cast_to_cells(context, instance, 'evacuate',
host, *args, **kwargs)
开发者ID:andymcc,项目名称:nova,代码行数:6,代码来源:cells_api.py
注:本文中的nova.cells.utils.split_cell_and_item函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论