本文整理汇总了Python中nailgun.network.manager.NetworkManager.assign_admin_ips方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkManager.assign_admin_ips方法的具体用法?Python NetworkManager.assign_admin_ips怎么用?Python NetworkManager.assign_admin_ips使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.network.manager.NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.assign_admin_ips方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_for_provisioning
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_provisioning(cls, nodes):
"""Prepare environment for provisioning,
update fqdns, assign admin IPs
"""
cls.update_slave_nodes_fqdn(nodes)
for node in nodes:
NetworkManager.assign_admin_ips(node.id)
示例2: prepare_for_provisioning
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_provisioning(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
netmanager = NetworkManager()
for node in TaskHelper.nodes_to_provision(self):
netmanager.assign_admin_ips(
node.id, len(node.meta.get('interfaces', [])))
示例3: prepare_for_provisioning
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_provisioning(cls, nodes):
"""Prepare environment for provisioning,
update fqdns, assign admin ips
"""
cls.update_slave_nodes_fqdn(nodes)
for node in nodes:
NetworkManager.assign_admin_ips(
node.id, len(node.meta.get('interfaces', [])))
示例4: prepare_for_provisioning
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_provisioning(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
netmanager = NetworkManager()
nodes = TaskHelper.nodes_to_provision(self)
TaskHelper.update_slave_nodes_fqdn(nodes)
for node in nodes:
netmanager.assign_admin_ips(node.id, len(node.meta.get("interfaces", [])))
示例5: prepare_for_deployment
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_deployment(cls, nodes):
"""Prepare environment for deployment,
assign management, public, storage ips
"""
cls.update_slave_nodes_fqdn(nodes)
nodes_ids = [n.id for n in nodes]
netmanager = NetworkManager()
if nodes_ids:
netmanager.assign_ips(nodes_ids, 'management')
netmanager.assign_ips(nodes_ids, 'public')
netmanager.assign_ips(nodes_ids, 'storage')
for node in nodes:
netmanager.assign_admin_ips(
node.id, len(node.meta.get('interfaces', [])))
示例6: prepare_for_deployment
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def prepare_for_deployment(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
nodes = sorted(
set(TaskHelper.nodes_to_deploy(self) + TaskHelper.nodes_in_provisioning(self)), key=lambda node: node.id
)
TaskHelper.update_slave_nodes_fqdn(nodes)
nodes_ids = [n.id for n in nodes]
netmanager = NetworkManager()
if nodes_ids:
netmanager.assign_ips(nodes_ids, "management")
netmanager.assign_ips(nodes_ids, "public")
netmanager.assign_ips(nodes_ids, "storage")
for node in nodes:
netmanager.assign_admin_ips(node.id, len(node.meta.get("interfaces", [])))
示例7: test_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
'dev': 'eth0',
'netmask': '255.255.255.0',
'brd': '172.16.0.255',
'gateway': u'172.16.0.1'},
{'vlan': 100,
'name': 'floating',
'dev': 'eth0'},
{'vlan': 101,
'name': 'fixed',
'dev': 'eth0'},
{'name': u'admin',
'dev': 'eth0'}]})
pnd = {
'profile': cluster_attrs['cobbler']['profile'],
'power_type': 'ssh',
'power_user': 'root',
'power_address': n.ip,
'power_pass': settings.PATH_TO_BOOTSTRAP_SSH_KEY,
'name': TaskHelper.make_slave_name(n.id, n.role),
'hostname': n.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_version': settings.PUPPET_VERSION,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'ks_spaces': "\"%s\"" % json.dumps(
n.attributes.volumes).replace("\"", "\\\""),
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
}
}
netmanager = NetworkManager()
netmanager.assign_admin_ips(
n.id,
len(n.meta.get('interfaces', []))
)
admin_ips = set([i.ip_addr for i in self.db.query(IPAddr).
filter_by(node=n.id).
filter_by(network=admin_net_id)])
for i in n.meta.get('interfaces', []):
if 'interfaces' not in pnd:
pnd['interfaces'] = {}
pnd['interfaces'][i['name']] = {
'mac_address': i['mac'],
'static': '0',
'netmask': settings.ADMIN_NETWORK['netmask'],
'ip_address': admin_ips.pop(),
}
if 'interfaces_extra' not in pnd:
pnd['interfaces_extra'] = {}
pnd['interfaces_extra'][i['name']] = {
'peerdns': 'no',
'onboot': 'no'
}
if i['mac'] == n.mac:
pnd['interfaces'][i['name']]['dns_name'] = n.fqdn
pnd['interfaces_extra'][i['name']]['onboot'] = 'yes'
provision_nodes.append(pnd)
controller_nodes = filter(
lambda node: node['role'] == 'controller',
nodes)
msg['args']['attributes']['controller_nodes'] = controller_nodes
msg['args']['nodes'] = nodes
provision_task_uuid = [x.uuid for x in supertask.subtasks
if x.name == 'provision'][0]
provision_msg = {
'method': 'provision',
'respond_to': 'provision_resp',
'args': {
'task_uuid': provision_task_uuid,
'engine': {
'url': settings.COBBLER_URL,
'username': settings.COBBLER_USER,
'password': settings.COBBLER_PASSWORD,
},
'nodes': provision_nodes,
}
}
nailgun.task.manager.rpc.cast.assert_called_once_with(
'naily', [provision_msg, msg])
示例8: test_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
supertask = self.env.launch_deployment()
deploy_task_uuid = [x.uuid for x in supertask.subtasks
if x.name == 'deployment'][0]
deployment_msg = {'method': 'deploy',
'respond_to': 'deploy_resp',
'args': {}}
deployment_msg['args']['task_uuid'] = deploy_task_uuid
deployment_msg['args']['deployment_info'] = deployment_info
provision_nodes = []
admin_net_id = self.env.network_manager.get_admin_network_id()
for n in sorted(self.env.nodes, key=lambda n: n.id):
pnd = {
'profile': cluster_attrs['cobbler']['profile'],
'power_type': 'ssh',
'power_user': 'root',
'power_address': n.ip,
'power_pass': settings.PATH_TO_BOOTSTRAP_SSH_KEY,
'name': TaskHelper.make_slave_name(n.id),
'hostname': n.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_version': settings.PUPPET_VERSION,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'ks_spaces': "\"%s\"" % json.dumps(
n.attributes.volumes).replace("\"", "\\\""),
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
}
}
netmanager = NetworkManager()
netmanager.assign_admin_ips(
n.id,
len(n.meta.get('interfaces', []))
)
admin_ips = set([i.ip_addr for i in self.db.query(IPAddr).
filter_by(node=n.id).
filter_by(network=admin_net_id)])
for i in n.meta.get('interfaces', []):
if 'interfaces' not in pnd:
pnd['interfaces'] = {}
pnd['interfaces'][i['name']] = {
'mac_address': i['mac'],
'static': '0',
'netmask': settings.ADMIN_NETWORK['netmask'],
'ip_address': admin_ips.pop(),
}
if 'interfaces_extra' not in pnd:
pnd['interfaces_extra'] = {}
pnd['interfaces_extra'][i['name']] = {
'peerdns': 'no',
'onboot': 'no'
}
if i['mac'] == n.mac:
pnd['interfaces'][i['name']]['dns_name'] = n.fqdn
pnd['interfaces_extra'][i['name']]['onboot'] = 'yes'
provision_nodes.append(pnd)
provision_task_uuid = filter(
lambda t: t.name == 'provision',
supertask.subtasks)[0].uuid
provision_msg = {
'method': 'provision',
'respond_to': 'provision_resp',
'args': {
'task_uuid': provision_task_uuid,
'provisioning_info': {
'engine': {
'url': settings.COBBLER_URL,
'username': settings.COBBLER_USER,
'password': settings.COBBLER_PASSWORD},
'nodes': provision_nodes}}}
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEquals(len(args), 2)
self.assertEquals(len(args[1]), 2)
self.datadiff(args[1][0], provision_msg)
self.datadiff(args[1][1], deployment_msg)
示例9: test_neutron_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
'args': {}}
deployment_msg['args']['task_uuid'] = deploy_task_uuid
deployment_msg['args']['deployment_info'] = deployment_info
provision_nodes = []
admin_net = self.env.network_manager.get_admin_network_group()
for n in sorted(self.env.nodes, key=lambda n: n.id):
udev_interfaces_mapping = ','.join([
'{0}_{1}'.format(i.mac, i.name) for i in n.interfaces])
eth1_mac = [i.mac for i in n.interfaces if i.name == 'eth1'][0]
pnd = {
'profile': cluster_attrs['cobbler']['profile'],
'power_type': 'ssh',
'power_user': 'root',
'kernel_options': {
'netcfg/choose_interface': eth1_mac,
'udevrules': udev_interfaces_mapping},
'power_address': n.ip,
'power_pass': settings.PATH_TO_BOOTSTRAP_SSH_KEY,
'name': TaskHelper.make_slave_name(n.id),
'hostname': n.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_version': settings.PUPPET_VERSION,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'ks_spaces': n.attributes.volumes,
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
}
}
NetworkManager.assign_admin_ips(
n.id,
len(n.meta.get('interfaces', []))
)
admin_ips = set([i.ip_addr
for i in self.db.query(IPAddr).
filter_by(node=n.id).
filter_by(network=admin_net.id)])
for i in n.meta.get('interfaces', []):
if 'interfaces' not in pnd:
pnd['interfaces'] = {}
pnd['interfaces'][i['name']] = {
'mac_address': i['mac'],
'static': '0',
'netmask': admin_net.netmask,
'ip_address': admin_ips.pop(),
}
if 'interfaces_extra' not in pnd:
pnd['interfaces_extra'] = {}
pnd['interfaces_extra'][i['name']] = {
'peerdns': 'no',
'onboot': 'no'
}
if i['mac'] == n.mac:
pnd['interfaces'][i['name']]['dns_name'] = n.fqdn
pnd['interfaces_extra'][i['name']]['onboot'] = 'yes'
provision_nodes.append(pnd)
provision_task_uuid = filter(
lambda t: t.name == 'provision',
supertask.subtasks)[0].uuid
provision_msg = {
'method': 'provision',
'respond_to': 'provision_resp',
'args': {
'task_uuid': provision_task_uuid,
'provisioning_info': {
'engine': {
'url': settings.COBBLER_URL,
'username': settings.COBBLER_USER,
'password': settings.COBBLER_PASSWORD},
'nodes': provision_nodes}}}
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEquals(len(args), 2)
self.assertEquals(len(args[1]), 2)
self.datadiff(args[1][0], provision_msg)
self.datadiff(args[1][1], deployment_msg)
示例10: test_nova_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
udev_interfaces_mapping = ','.join([
'{0}_{1}'.format(i.mac, i.name) for i in n.interfaces])
eth1_mac = [i.mac for i in n.interfaces if i.name == 'eth1'][0]
pnd = {
'profile': cluster_attrs['cobbler']['profile'],
'power_type': 'ssh',
'power_user': 'root',
'kernel_options': {
'netcfg/choose_interface': eth1_mac,
'udevrules': udev_interfaces_mapping},
'power_address': n.ip,
'power_pass': settings.PATH_TO_BOOTSTRAP_SSH_KEY,
'name': objects.Node.make_slave_name(n),
'hostname': n.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'fuel_version': cluster_db.fuel_version,
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'pm_data': {
'ks_spaces': n.attributes.volumes,
'kernel_params': n.kernel_params,
},
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
}
}
orchestrator_data = objects.Release.get_orchestrator_data_dict(
cluster_db.release)
if orchestrator_data:
pnd['ks_meta']['repo_metadata'] = \
orchestrator_data['repo_metadata']
vlan_splinters = cluster_attrs.get('vlan_splinters', None)
if vlan_splinters == 'kernel_lt':
pnd['ks_meta']['kernel_lt'] = 1
NetworkManager.assign_admin_ips(n.id, 1)
admin_ip = self.env.network_manager.get_admin_ip_for_node(n)
for i in n.interfaces:
if 'interfaces' not in pnd:
pnd['interfaces'] = {}
pnd['interfaces'][i.name] = {
'mac_address': i.mac,
'static': '0',
}
if 'interfaces_extra' not in pnd:
pnd['interfaces_extra'] = {}
pnd['interfaces_extra'][i.name] = {
'peerdns': 'no',
'onboot': 'no'
}
if i.mac == n.mac:
pnd['interfaces'][i.name]['dns_name'] = n.fqdn
pnd['interfaces_extra'][i.name]['onboot'] = 'yes'
pnd['interfaces'][i.name]['ip_address'] = admin_ip
pnd['interfaces'][i.name]['netmask'] = str(
netaddr.IPNetwork(admin_net.cidr).netmask)
provision_nodes.append(pnd)
provision_task_uuid = filter(
lambda t: t.name == 'provision',
supertask.subtasks)[0].uuid
provision_msg = {
'api_version': '1',
'method': 'provision',
'respond_to': 'provision_resp',
'args': {
'task_uuid': provision_task_uuid,
'provisioning_info': {
'engine': {
'url': settings.COBBLER_URL,
'username': settings.COBBLER_USER,
'password': settings.COBBLER_PASSWORD,
'master_ip': settings.MASTER_IP},
'nodes': provision_nodes}}}
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEqual(len(args), 2)
self.assertEqual(len(args[1]), 2)
self.datadiff(args[1][0], provision_msg)
self.datadiff(args[1][1], deployment_msg)
示例11: message
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
def message(cls, task):
logger.debug("ProvisionTask.message(task=%s)" % task.uuid)
# this variable is used to set 'auth_key' in cobbler ks_meta
cluster_attrs = task.cluster.attributes.merged_attrs_values()
nodes = TaskHelper.nodes_to_provision(task.cluster)
netmanager = NetworkManager()
USE_FAKE = settings.FAKE_TASKS or settings.FAKE_TASKS_AMQP
# TODO: For now we send nodes data to orchestrator
# which is cobbler oriented. But for future we
# need to use more abstract data structure.
nodes_data = []
for node in nodes:
if not node.online:
if not USE_FAKE:
raise Exception(
u"Node '%s' (id=%s) is offline."
" Remove it from environment and try again." %
(node.name, node.id)
)
else:
logger.warning(
u"Node '%s' (id=%s) is offline."
" Remove it from environment and try again." %
(node.name, node.id)
)
node_data = {
'profile': settings.COBBLER_PROFILE,
'power_type': 'ssh',
'power_user': 'root',
'power_address': node.ip,
'name': TaskHelper.make_slave_name(node.id, node.role),
'hostname': node.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_version': settings.PUPPET_VERSION,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
'ks_spaces': "\"%s\"" % json.dumps(
node.attributes.volumes).replace("\"", "\\\"")
}
}
if node.status == "discover":
logger.info(
"Node %s seems booted with bootstrap image",
node.id
)
node_data['power_pass'] = settings.PATH_TO_BOOTSTRAP_SSH_KEY
else:
# If it's not in discover, we expect it to be booted
# in target system.
# TODO: Get rid of expectations!
logger.info(
"Node %s seems booted with real system",
node.id
)
node_data['power_pass'] = settings.PATH_TO_SSH_KEY
# FIXME: move this code (updating) into receiver.provision_resp
if not USE_FAKE:
node.status = "provisioning"
orm().add(node)
orm().commit()
# here we assign admin network IPs for node
# one IP for every node interface
netmanager.assign_admin_ips(
node.id,
len(node.meta.get('interfaces', []))
)
admin_net_id = netmanager.get_admin_network_id()
admin_ips = set([i.ip_addr for i in orm().query(IPAddr).
filter_by(node=node.id).
filter_by(network=admin_net_id)])
for i in node.meta.get('interfaces', []):
if 'interfaces' not in node_data:
node_data['interfaces'] = {}
node_data['interfaces'][i['name']] = {
'mac_address': i['mac'],
'static': '0',
'netmask': settings.ADMIN_NETWORK['netmask'],
'ip_address': admin_ips.pop(),
}
# interfaces_extra field in cobbler ks_meta
# means some extra data for network interfaces
#.........这里部分代码省略.........
示例12: test_neutron_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
'udevrules': udev_interfaces_mapping},
'power_address': n.ip,
'power_pass': settings.PATH_TO_BOOTSTRAP_SSH_KEY,
'name': objects.Node.make_slave_name(n),
'hostname': n.fqdn,
'name_servers': '\"%s\"' % settings.DNS_SERVERS,
'name_servers_search': '\"%s\"' % settings.DNS_SEARCH,
'netboot_enabled': '1',
'ks_meta': {
'fuel_version': cluster_db.fuel_version,
'puppet_auto_setup': 1,
'puppet_master': settings.PUPPET_MASTER_HOST,
'puppet_enable': 0,
'mco_auto_setup': 1,
'install_log_2_syslog': 1,
'mco_pskey': settings.MCO_PSKEY,
'mco_vhost': settings.MCO_VHOST,
'mco_host': settings.MCO_HOST,
'mco_user': settings.MCO_USER,
'mco_password': settings.MCO_PASSWORD,
'mco_connector': settings.MCO_CONNECTOR,
'mco_enable': 1,
'pm_data': {
'ks_spaces': n.attributes.volumes,
'kernel_params': objects.Node.get_kernel_params(n),
},
'auth_key': "\"%s\"" % cluster_attrs.get('auth_key', ''),
'authorized_keys':
["\"%s\"" % key for key in settings.AUTHORIZED_KEYS],
'timezone': settings.TIMEZONE,
'master_ip': settings.MASTER_IP,
'mlnx_vf_num': "16",
'mlnx_plugin_mode': "disabled",
'mlnx_iser_enabled': False,
'image_data': cluster_attrs['provision']['image_data']
}
}
orchestrator_data = objects.Release.get_orchestrator_data_dict(
cluster_db.release)
if orchestrator_data:
pnd['ks_meta']['repo_metadata'] = \
orchestrator_data['repo_metadata']
vlan_splinters = cluster_attrs.get('vlan_splinters', None)
if vlan_splinters == 'kernel_lt':
pnd['ks_meta']['kernel_lt'] = 1
NetworkManager.assign_admin_ips(n.id, 1)
admin_ip = self.env.network_manager.get_admin_ip_for_node(n)
for i in n.meta.get('interfaces', []):
if 'interfaces' not in pnd:
pnd['interfaces'] = {}
pnd['interfaces'][i['name']] = {
'mac_address': i['mac'],
'static': '0',
}
if 'interfaces_extra' not in pnd:
pnd['interfaces_extra'] = {}
pnd['interfaces_extra'][i['name']] = {
'peerdns': 'no',
'onboot': 'no'
}
if i['mac'] == n.mac:
pnd['interfaces'][i['name']]['dns_name'] = n.fqdn
pnd['interfaces_extra'][i['name']]['onboot'] = 'yes'
pnd['interfaces'][i['name']]['ip_address'] = admin_ip
pnd['interfaces'][i['name']]['netmask'] = str(
netaddr.IPNetwork(admin_net.cidr).netmask)
provision_nodes.append(pnd)
provision_task_uuid = filter(
lambda t: t.name == 'provision',
supertask.subtasks)[0].uuid
provision_msg = {
'api_version': '1',
'method': 'provision',
'respond_to': 'provision_resp',
'args': {
'task_uuid': provision_task_uuid,
'provisioning_info': {
'engine': {
'url': settings.COBBLER_URL,
'username': settings.COBBLER_USER,
'password': settings.COBBLER_PASSWORD,
'master_ip': settings.MASTER_IP,
'provision_method': consts.PROVISION_METHODS.image
},
'nodes': provision_nodes}}}
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEqual(len(args), 2)
self.assertEqual(len(args[1]), 2)
self.datadiff(args[1][0], provision_msg)
self.datadiff(args[1][1], deployment_msg)
示例13: test_nova_deploy_cast_with_right_args
# 需要导入模块: from nailgun.network.manager import NetworkManager [as 别名]
# 或者: from nailgun.network.manager.NetworkManager import assign_admin_ips [as 别名]
#.........这里部分代码省略.........
)
deployment_info.append(deepcopy(individual_atts))
controller_nodes = filter(lambda node: node["role"] == "controller", deployment_info)
controller_nodes[0]["role"] = "primary-controller"
supertask = self.env.launch_deployment()
deploy_task_uuid = [x.uuid for x in supertask.subtasks if x.name == "deployment"][0]
deployment_msg = {"method": "deploy", "respond_to": "deploy_resp", "args": {}}
deployment_msg["args"]["task_uuid"] = deploy_task_uuid
deployment_msg["args"]["deployment_info"] = deployment_info
provision_nodes = []
admin_net = self.env.network_manager.get_admin_network()
for n in sorted(self.env.nodes, key=lambda n: n.id):
udev_interfaces_mapping = ",".join(["{0}_{1}".format(i.mac, i.name) for i in n.interfaces])
pnd = {
"profile": cluster_attrs["cobbler"]["profile"],
"power_type": "ssh",
"power_user": "root",
"kernel_options": {"netcfg/choose_interface": "eth1", "udevrules": udev_interfaces_mapping},
"power_address": n.ip,
"power_pass": settings.PATH_TO_BOOTSTRAP_SSH_KEY,
"name": TaskHelper.make_slave_name(n.id),
"hostname": n.fqdn,
"name_servers": '"%s"' % settings.DNS_SERVERS,
"name_servers_search": '"%s"' % settings.DNS_SEARCH,
"netboot_enabled": "1",
"ks_meta": {
"puppet_auto_setup": 1,
"puppet_master": settings.PUPPET_MASTER_HOST,
"puppet_version": settings.PUPPET_VERSION,
"puppet_enable": 0,
"mco_auto_setup": 1,
"install_log_2_syslog": 1,
"mco_pskey": settings.MCO_PSKEY,
"mco_vhost": settings.MCO_VHOST,
"mco_host": settings.MCO_HOST,
"mco_user": settings.MCO_USER,
"mco_password": settings.MCO_PASSWORD,
"mco_connector": settings.MCO_CONNECTOR,
"mco_enable": 1,
"ks_spaces": n.attributes.volumes,
"auth_key": '"%s"' % cluster_attrs.get("auth_key", ""),
},
}
NetworkManager.assign_admin_ips(n.id, len(n.meta.get("interfaces", [])))
admin_ips = set(
[i.ip_addr for i in self.db.query(IPAddr).filter_by(node=n.id).filter_by(network=admin_net.id)]
)
for i in n.meta.get("interfaces", []):
if "interfaces" not in pnd:
pnd["interfaces"] = {}
pnd["interfaces"][i["name"]] = {
"mac_address": i["mac"],
"static": "0",
"netmask": admin_net.network_group.netmask,
"ip_address": admin_ips.pop(),
}
if "interfaces_extra" not in pnd:
pnd["interfaces_extra"] = {}
pnd["interfaces_extra"][i["name"]] = {"peerdns": "no", "onboot": "no"}
if i["mac"] == n.mac:
pnd["interfaces"][i["name"]]["dns_name"] = n.fqdn
pnd["interfaces_extra"][i["name"]]["onboot"] = "yes"
provision_nodes.append(pnd)
provision_task_uuid = filter(lambda t: t.name == "provision", supertask.subtasks)[0].uuid
provision_msg = {
"method": "provision",
"respond_to": "provision_resp",
"args": {
"task_uuid": provision_task_uuid,
"provisioning_info": {
"engine": {
"url": settings.COBBLER_URL,
"username": settings.COBBLER_USER,
"password": settings.COBBLER_PASSWORD,
},
"nodes": provision_nodes,
},
},
}
args, kwargs = nailgun.task.manager.rpc.cast.call_args
self.assertEquals(len(args), 2)
self.assertEquals(len(args[1]), 2)
self.datadiff(args[1][0], provision_msg)
self.datadiff(args[1][1], deployment_msg)