import tempfile
import apex.virtual.configure_vm as vm_lib
-import apex.virtual.virtual_utils as virt_utils
+import apex.virtual.utils as virt_utils
from apex import DeploySettings
from apex import Inventory
from apex import NetworkEnvironment
raise ApexDeployException("Setting a DPDK based dataplane requires"
"a dedicated NIC for tenant network")
+ if 'odl_vpp_routing_node' in deploy_settings['deploy_options']:
+ if deploy_settings['deploy_options']['dataplane'] != 'fdio':
+ raise ApexDeployException("odl_vpp_routing_node should only be set"
+ "when dataplane is set to fdio")
+ if deploy_settings['deploy_options'].get('dvr') is True:
+ raise ApexDeployException("odl_vpp_routing_node should only be set"
+ "when dvr is not enabled")
+
# TODO(trozet): add more checks here like RAM for ODL, etc
# check if odl_vpp_netvirt is true and vpp is set
# Check if fdio and nosdn:
overcloud_deploy.prep_image(deploy_settings, sdn_image, APEX_TEMP_DIR,
root_pw=root_pw)
opnfv_env = os.path.join(args.deploy_dir, args.env_file)
- overcloud_deploy.prep_env(deploy_settings, net_settings, opnfv_env,
- net_env_target, APEX_TEMP_DIR)
+ overcloud_deploy.prep_env(deploy_settings, net_settings, inventory,
+ opnfv_env, net_env_target, APEX_TEMP_DIR)
overcloud_deploy.create_deploy_cmd(deploy_settings, net_settings,
inventory, APEX_TEMP_DIR,
args.virtual, args.env_file)
from apex.common import constants as con
from apex.common.exceptions import ApexDeployException
from apex.common import parsers
-from apex.virtual import virtual_utils as virt_utils
+from apex.virtual import utils as virt_utils
from cryptography.hazmat.primitives import serialization as \
crypto_serialization
from cryptography.hazmat.primitives.asymmetric import rsa
'gluon': 'gluon.yaml',
'vpp': {
'odl_vpp_netvirt': 'neutron-opendaylight-netvirt-vpp.yaml',
+ 'dvr': 'neutron-opendaylight-fdio-dvr.yaml',
'default': 'neutron-opendaylight-honeycomb.yaml'
},
'default': 'neutron-opendaylight.yaml',
return env_list
+ def _get_node_counts(inventory):
+ """
+ Return numbers of controller and compute nodes in inventory
+
+ :param inventory: node inventory data structure
+ :return: number of controller and compute nodes in inventory
+ """
+ if not inventory:
+ raise ApexDeployException("Empty inventory")
+
+ nodes = inventory['nodes']
+ num_control = 0
+ num_compute = 0
+ for node in nodes:
+ if node['capabilities'] == 'profile:control':
+ num_control += 1
+ elif node['capabilities'] == 'profile:compute':
+ num_compute += 1
+ else:
+ # TODO(trozet) do we want to allow capabilities to not exist?
+ logging.error("Every node must include a 'capabilities' key "
+ "tagged with either 'profile:control' or "
+ "'profile:compute'")
+ raise ApexDeployException("Node missing capabilities "
+ "key: {}".format(node))
+ return num_control, num_compute
+
+
def create_deploy_cmd(ds, ns, inv, tmp_dir,
virtual, env_file='opnfv-environment.yaml'):
ds_opts = ds['deploy_options']
deploy_options += build_sdn_env_list(ds_opts, SDN_FILE_MAP)
- # TODO(trozet): make sure rt kvm file is in tht dir
for k, v in OTHER_FILE_MAP.items():
if k in ds_opts and ds_opts[k]:
deploy_options.append(os.path.join(con.THT_ENV_DIR, v))
else:
deploy_options.append('baremetal-environment.yaml')
- nodes = inv['nodes']
- num_control = 0
- num_compute = 0
- for node in nodes:
- if 'profile:control' in node['capabilities']:
- num_control += 1
- elif 'profile:compute' in node['capabilities']:
- num_compute += 1
- else:
- # TODO(trozet) do we want to allow capabilities to not exist?
- logging.error("Every node must include a 'capabilities' key "
- "tagged with either 'profile:control' or "
- "'profile:compute'")
- raise ApexDeployException("Node missing capabilities "
- "key: {}".format(node))
+ num_control, num_compute = _get_node_counts(inv)
if num_control == 0 or num_compute == 0:
logging.error("Detected 0 control or compute nodes. Control nodes: "
"{}, compute nodes{}".format(num_control, num_compute))
if ds_opts['odl_version'] != con.DEFAULT_ODL_VERSION:
virt_cmds.extend([
{con.VIRT_RUN_CMD: "yum -y remove opendaylight"},
- {con.VIRT_RUN_CMD: "yum -y install /root/{}/*".format(
- ds_opts['odl_version'])},
{con.VIRT_RUN_CMD: "rm -rf /etc/puppet/modules/opendaylight"},
{con.VIRT_RUN_CMD: "cd /etc/puppet/modules && tar xzf "
"/root/puppet-opendaylight-"
"{}.tar.gz".format(ds_opts['odl_version'])}
])
+ if ds_opts['odl_version'] == 'master':
+ virt_cmds.extend([
+ {con.VIRT_RUN_CMD: "rpm -ivh --nodeps /root/{}/*".format(
+ ds_opts['odl_version'])}
+ ])
+ else:
+ virt_cmds.extend([
+ {con.VIRT_RUN_CMD: "yum -y install /root/{}/*".format(
+ ds_opts['odl_version'])}
+ ])
+
elif sdn == 'opendaylight' and 'odl_vpp_netvirt' in ds_opts \
and ds_opts['odl_vpp_netvirt']:
virt_cmds.extend([
return private_key.decode('utf-8'), pub_key
- def prep_env(ds, ns, opnfv_env, net_env, tmp_dir):
+ def prep_env(ds, ns, inv, opnfv_env, net_env, tmp_dir):
"""
Creates modified opnfv/network environments for deployment
:param ds: deploy settings
:param ns: network settings
+ :param inv: node inventory
:param opnfv_env: file path for opnfv-environment file
:param net_env: file path for network-environment file
:param tmp_dir: Apex tmp dir
output_line = " key: '{}'".format(public_key)
if ds_opts['sdn_controller'] == 'opendaylight' and \
- 'odl_vpp_routing_node' in ds_opts and ds_opts[
- 'odl_vpp_routing_node'] != 'dvr':
+ 'odl_vpp_routing_node' in ds_opts:
if 'opendaylight::vpp_routing_node' in line:
- output_line = (" opendaylight::vpp_routing_node: ${}.${}"
+ output_line = (" opendaylight::vpp_routing_node: {}.{}"
.format(ds_opts['odl_vpp_routing_node'],
ns['domain_name']))
elif 'ControllerExtraConfig' in line:
if 'NeutronVPPAgentPhysnets' in line:
output_line = (" NeutronVPPAgentPhysnets: 'datacentre:{}'".
format(tenant_ctrl_nic))
+ elif ds_opts['sdn_controller'] == 'opendaylight' and ds_opts.get(
+ 'dvr') is True:
+ if 'OS::TripleO::Services::NeutronDhcpAgent' in line:
+ output_line = ''
+ elif 'NeutronDhcpAgentsPerNetwork' in line:
+ num_control, num_compute = _get_node_counts(inv)
+ output_line = (" NeutronDhcpAgentsPerNetwork: {}"
+ .format(num_compute))
+ elif 'ComputeServices' in line:
+ output_line = (" ComputeServices:\n"
+ " - OS::TripleO::Services::NeutronDhcpAgent")
if perf:
for role in 'NovaCompute', 'Controller':
ds_opts['dataplane'] == 'ovs_dpdk':
print(' OS::TripleO::ComputeExtraConfigPre: '
'./ovs-dpdk-preconfig.yaml')
- elif perf and perf_kern_comp:
- if 'resource_registry' in line:
- print("resource_registry:\n"
- " OS::TripleO::NodeUserData: first-boot.yaml")
- elif 'NovaSchedulerDefaultFilters' in line:
- print(" NovaSchedulerDefaultFilters: 'RamFilter,"
- "ComputeFilter,AvailabilityZoneFilter,"
- "ComputeCapabilitiesFilter,ImagePropertiesFilter,"
- "NUMATopologyFilter'")
- else:
- print(line)
+ elif ((perf and perf_kern_comp) or ds_opts.get('rt_kvm')) and \
+ 'resource_registry' in line:
+ print("resource_registry:\n"
+ " OS::TripleO::NodeUserData: first-boot.yaml")
+ elif perf and perf_kern_comp and \
+ 'NovaSchedulerDefaultFilters' in line:
+ print(" NovaSchedulerDefaultFilters: 'RamFilter,"
+ "ComputeFilter,AvailabilityZoneFilter,"
+ "ComputeCapabilitiesFilter,ImagePropertiesFilter,"
+ "NUMATopologyFilter'")
else:
print(line)