本文整理汇总了Python中nailgun.network.manager.NetworkManager.get_node_networks方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_node_networks方法的具体用法?Python NetworkManager.get_node_networks怎么用?Python NetworkManager.get_node_networks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.get_node_networks方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def render(cls, instance, fields=None):
json_data = JSONHandler.render(instance, fields=cls.fields)
network_manager = NetworkManager()
json_data['network_data'] = network_manager.get_node_networks(
instance.id
)
return json_data
示例2: render
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def render(cls, instance, fields=None):
json_data = None
try:
json_data = BaseHandler.render(instance, fields=cls.fields)
json_data['network_data'] = NetworkManager.get_node_networks(
instance.id)
except Exception:
logger.error(traceback.format_exc())
return json_data
示例3: __format_node_for_naily
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def __format_node_for_naily(cls, n):
netmanager = NetworkManager()
return {
'id': n.id, 'status': n.status, 'error_type': n.error_type,
'uid': n.id, 'ip': n.ip, 'mac': n.mac, 'role': n.role,
'fqdn': n.fqdn, 'progress': n.progress, 'meta': n.meta,
'network_data': netmanager.get_node_networks(n.id),
'online': n.online
}
示例4: _success_action
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def _success_action(cls, task, status, progress):
network_manager = NetworkManager()
# check if all nodes are ready
if any(map(lambda n: n.status == "error", task.cluster.nodes)):
cls._error_action(task, "error", 100)
return
if task.cluster.mode in ("singlenode", "multinode"):
# determining horizon url - it's an IP
# of a first cluster controller
controller = (
db()
.query(Node)
.filter_by(cluster_id=task.cluster_id)
.filter(Node.role_list.any(name="controller"))
.first()
)
if controller:
logger.debug(u"Controller is found, node_id=%s, " "getting it's IP addresses", controller.id)
public_net = filter(
lambda n: n["name"] == "public" and "ip" in n, network_manager.get_node_networks(controller.id)
)
if public_net:
horizon_ip = public_net[0]["ip"].split("/")[0]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at "
"http://{1}/ or via internal network at http://{2}/"
).format(task.cluster.name, horizon_ip, controller.ip)
else:
message = (u"Deployment of environment '{0}' is done").format(task.cluster.name)
logger.warning(u"Public ip for controller node " "not found in '{0}'".format(task.cluster.name))
else:
message = (u"Deployment of environment" " '{0}' is done").format(task.cluster.name)
logger.warning(u"Controller node not found in '{0}'".format(task.cluster.name))
elif task.cluster.mode == "ha":
# determining horizon url in HA mode - it's vip
# from a public network saved in task cache
args = task.cache.get("args")
try:
vip = args["attributes"]["public_vip"]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at http://{1}/"
).format(task.cluster.name, vip)
except Exception as exc:
logger.error(": ".join([str(exc), traceback.format_exc()]))
message = (u"Deployment of environment" " '{0}' is done").format(task.cluster.name)
logger.warning(u"Cannot find virtual IP for '{0}'".format(task.cluster.name))
notifier.notify("done", message, task.cluster_id)
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例5: network_data
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def network_data(self):
# It is required for integration tests; to get info about nets
# which must be created on target node
from nailgun.network.manager import NetworkManager
netmanager = NetworkManager()
return netmanager.get_node_networks(self.id)
示例6: network_data
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def network_data(self):
# TODO(enchantner): move to object
from nailgun.network.manager import NetworkManager
return NetworkManager.get_node_networks(self)
示例7: network_data
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def network_data(self):
from nailgun.network.manager import NetworkManager
return NetworkManager.get_node_networks(self.id)
示例8: _success_action
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_node_networks [as 别名]
def _success_action(cls, task, status, progress):
# check if all nodes are ready
if any(map(lambda n: n.status == 'error',
task.cluster.nodes)):
cls._error_action(task, 'error', 100)
return
if task.cluster.mode in ('singlenode', 'multinode'):
# determining horizon url - it's an IP
# of a first cluster controller
controller = db().query(Node).filter_by(
cluster_id=task.cluster_id
).filter(Node.role_list.any(name='controller')).first()
if controller:
logger.debug(
u"Controller is found, node_id=%s, "
"getting it's IP addresses",
controller.id
)
public_net = filter(
lambda n: n['name'] == 'public' and 'ip' in n,
NetworkManager.get_node_networks(controller.id)
)
if public_net:
horizon_ip = public_net[0]['ip'].split('/')[0]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at "
"http://{1}/ or via internal network at http://{2}/"
).format(
task.cluster.name,
horizon_ip,
controller.ip
)
else:
message = (
u"Deployment of environment '{0}' is done"
).format(task.cluster.name)
logger.warning(
u"Public ip for controller node "
"not found in '{0}'".format(task.cluster.name)
)
else:
message = (
u"Deployment of environment"
" '{0}' is done"
).format(task.cluster.name)
logger.warning(u"Controller node not found in '{0}'".format(
task.cluster.name
))
elif task.cluster.is_ha_mode:
# determining horizon url in HA mode - it's vip
# from a public network saved in task cache
try:
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at {1}"
).format(
task.cluster.name,
NetworkManager.get_horizon_url(task.cluster.id)
)
except Exception as exc:
logger.error(": ".join([
str(exc),
traceback.format_exc()
]))
message = (
u"Deployment of environment"
" '{0}' is done"
).format(task.cluster.name)
logger.warning(
u"Cannot find virtual IP for '{0}'".format(
task.cluster.name
)
)
notifier.notify(
"done",
message,
task.cluster_id
)
TaskHelper.update_task_status(task.uuid, status, progress, message)