本文整理汇总了Python中cattle.Config.hostname方法的典型用法代码示例。如果您正苦于以下问题:Python Config.hostname方法的具体用法?Python Config.hostname怎么用?Python Config.hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cattle.Config
的用法示例。
在下文中一共展示了Config.hostname方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_resources
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import hostname [as 别名]
def _add_resources(self, ping, pong):
if not utils.ping_include_resources(ping):
return
physical_host = Config.physical_host()
compute = {
'type': 'host',
'kind': LIBVIRT_KIND,
'name': Config.hostname() + '/libvirt',
'uuid': LibvirtConfig.libvirt_uuid(),
'physicalHostUuid': physical_host['uuid'],
'data': {
'libvirt': {
'type': self.get_default_type()
}
}
}
resources = [physical_host, compute]
for driver in pool_drivers():
for pool in driver.discover(compute):
data = utils.get_map_value(pool, 'data', 'libvirt')
data['driver'] = driver.driver_name()
resources.append(pool)
utils.ping_add_resources(pong, *resources)
示例2: _add_resources
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import hostname [as 别名]
def _add_resources(self, ping, pong):
if not utils.ping_include_resources(ping):
return
stats = None
if utils.ping_include_stats(ping):
try:
stats = self.host_info.collect_data()
except:
log.exception("Error getting host info stats")
physical_host = Config.physical_host()
compute = {
'type': 'host',
'kind': 'docker',
'name': Config.hostname(),
'createLabels': self._get_host_create_labels(),
'labels': self._get_host_labels(),
'physicalHostUuid': physical_host['uuid'],
'uuid': DockerConfig.docker_uuid(),
'info': stats
}
pool = {
'type': 'storagePool',
'kind': 'docker',
'name': compute['name'] + ' Storage Pool',
'hostUuid': compute['uuid'],
'uuid': compute['uuid'] + '-pool'
}
resolved_ip = socket.gethostbyname(DockerConfig.docker_host_ip())
ip = {
'type': 'ipAddress',
'uuid': resolved_ip,
'address': resolved_ip,
'hostUuid': compute['uuid'],
}
proxy = Config.host_proxy()
if proxy is not None:
compute['apiProxy'] = proxy
utils.ping_add_resources(pong, physical_host, compute, pool, ip)
示例3: ping_post_process
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import hostname [as 别名]
def ping_post_process(req, resp):
hostname = Config.hostname()
pool_name = hostname + ' Storage Pool'
resources = resp['data']['resources']
uuid = 'c861f990-4472-4fa1-960f-65171b544c28'
instances = filter(lambda x: x['type'] == 'instance' and
x['uuid'] == uuid, resources)
assert len(instances) == 1
resources = filter(lambda x: x.get('kind') == 'docker', resources)
resources.append(instances[0])
resp['data']['resources'] = resources
assert resp['data']['resources'][0]['name'] == hostname
assert resp['data']['resources'][1]['name'] == pool_name
resp['data']['resources'][0]['name'] = 'localhost'
resp['data']['resources'][1]['name'] = 'localhost Storage Pool'
示例4: _add_resources
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import hostname [as 别名]
def _add_resources(self, ping, pong):
if not utils.ping_include_resources(ping):
return
stats = None
if utils.ping_include_stats(ping):
try:
stats = self.host_info.collect_data()
except:
log.exception("Error geting host info stats")
physical_host = Config.physical_host()
compute = {
"type": "host",
"kind": "docker",
"name": Config.hostname(),
"labels": Config.labels(),
"physicalHostUuid": physical_host["uuid"],
"uuid": DockerConfig.docker_uuid(),
"info": stats,
}
pool = {
"type": "storagePool",
"kind": "docker",
"name": compute["name"] + " Storage Pool",
"hostUuid": compute["uuid"],
"uuid": compute["uuid"] + "-pool",
}
ip = {
"type": "ipAddress",
"uuid": DockerConfig.docker_host_ip(),
"address": DockerConfig.docker_host_ip(),
"hostUuid": compute["uuid"],
}
proxy = Config.host_proxy()
if proxy is not None:
compute["apiProxy"] = proxy
utils.ping_add_resources(pong, physical_host, compute, pool, ip)
示例5: _add_resources
# 需要导入模块: from cattle import Config [as 别名]
# 或者: from cattle.Config import hostname [as 别名]
def _add_resources(self, ping, pong):
if not utils.ping_include_resources(ping):
return
physical_host = Config.physical_host()
compute = {
'type': 'host',
'kind': 'docker',
'name': Config.hostname(),
'physicalHostUuid': physical_host['uuid'],
'uuid': DockerConfig.docker_uuid()
}
pool = {
'type': 'storagePool',
'kind': 'docker',
'name': compute['name'] + ' Storage Pool',
'hostUuid': compute['uuid'],
'uuid': compute['uuid'] + '-pool'
}
utils.ping_add_resources(pong, physical_host, compute, pool)