本文整理汇总了Python中nailgun.network.manager.NetworkManager.get_end_point_ip方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.get_end_point_ip方法的具体用法?Python NetworkManager.get_end_point_ip怎么用?Python NetworkManager.get_end_point_ip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.get_end_point_ip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestOSTFHandler
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import get_end_point_ip [as 别名]
class TestOSTFHandler(BaseHandlers):
def setUp(self):
super(TestOSTFHandler, self).setUp()
self.netmanager = NetworkManager()
def get(self, cluster_id):
url = reverse(
'OSTFHandler',
kwargs={'cluster_id': cluster_id})
return self.app.get(url, headers=self.default_headers)
def assing_ip_to_nodes(self):
nodes_ids = [node.id for node in self.db.query(Node).all()]
self.netmanager.assign_ips(nodes_ids, 'management')
self.netmanager.assign_ips(nodes_ids, 'public')
map(self.netmanager.assign_admin_ips, nodes_ids)
def get_admin_network_cidr(self):
return db().query(Network).filter_by(
name="fuelweb_admin"
).first().cidr
def test_get_multinode_mode(self):
fqdn = 'fqdn.com'
self.env.create(
nodes_kwargs=[
{'role': 'compute'},
{'role': 'controller', 'fqdn': fqdn}])
self.assing_ip_to_nodes()
cluster_id = self.env.clusters[0].id
result = json.loads(self.get(cluster_id).body)
end_point_ip = self.netmanager.get_end_point_ip(cluster_id)
subnet = self.get_admin_network_cidr()
expected = {
'controller_nodes_ips': [SubnetMatcher(subnet)],
'horizon_url': 'http://%s/' % end_point_ip,
'controller_nodes_names': [fqdn],
'admin_tenant_name': 'admin',
'admin_username': 'admin',
'keystone_url': 'http://%s:5000/' % end_point_ip,
'admin_password': 'admin'}
self.assertDictContainsSubset(result, expected)
def test_get_ha_mode(self):
fqdns = ['fqdn1.com', 'fqdn2.com', 'fqdn3.com']
self.env.create(
cluster_kwargs={
'mode': 'ha',
'type': 'compute'},
nodes_kwargs=[
{'role': 'controller', 'fqdn': fqdns[0]},
{'role': 'controller', 'fqdn': fqdns[1]},
{'role': 'controller', 'fqdn': fqdns[2]}])
self.assing_ip_to_nodes()
cluster_id = self.env.clusters[0].id
result = json.loads(self.get(cluster_id).body)
end_point_ip = self.netmanager.get_end_point_ip(cluster_id)
subnets = [self.get_admin_network_cidr() for _ in range(3)]
expected = {
'controller_nodes_ips': map(SubnetMatcher, subnets),
'horizon_url': 'http://%s/' % end_point_ip,
'controller_nodes_names': sorted(fqdns),
'admin_tenant_name': 'admin',
'admin_username': 'admin',
'keystone_url': 'http://%s:5000/' % end_point_ip,
'admin_password': 'admin'}
self.assertDictContainsSubset(result, expected)