from apex import Inventory
from apex import NetworkEnvironment
from apex import NetworkSettings
+from apex.deployment.snapshot import SnapshotDeployment
from apex.common import utils
from apex.common import constants
from apex.common import parsers
from apex.common.exceptions import ApexDeployException
+from apex.deployment.tripleo import ApexDeployment
from apex.network import jumphost
from apex.network import network_data
from apex.undercloud import undercloud as uc_lib
SDN_IMAGE = 'overcloud-full-opendaylight.qcow2'
-def deploy_quickstart(args, deploy_settings_file, network_settings_file,
- inventory_file=None):
- pass
-
-
def validate_cross_settings(deploy_settings, net_settings, inventory):
"""
Used to validate compatibility across settings file.
help='File which contains Apex deploy settings')
deploy_parser.add_argument('-n', '--network-settings',
dest='network_settings_file',
- required=True,
+ required=False,
help='File which contains Apex network '
'settings')
deploy_parser.add_argument('-i', '--inventory-file',
default='/usr/share/opnfv-apex',
help='Directory path for apex ansible '
'and third party libs')
- deploy_parser.add_argument('--quickstart', action='store_true',
+ deploy_parser.add_argument('-s', '--snapshot', action='store_true',
default=False,
- help='Use tripleo-quickstart to deploy')
+ help='Use snapshots for deployment')
+ deploy_parser.add_argument('--snap-cache', dest='snap_cache',
+ default="{}/snap_cache".format(
+ os.path.expanduser('~')),
+ help='Local directory to cache snapshot '
+ 'artifacts. Defaults to $HOME/snap_cache')
deploy_parser.add_argument('--upstream', action='store_true',
default=True,
help='Force deployment to use upstream '
default=False,
help='Ignore fetching latest upstream and '
'use what is in cache')
+ deploy_parser.add_argument('-p', '--patches',
+ default='/etc/opnfv-apex/common-patches.yaml',
+ dest='patches_file',
+ help='File to include for common patches '
+ 'which apply to all deployment scenarios')
return deploy_parser
"""
logging.debug('Validating arguments for deployment')
- if args.virtual and args.inventory_file is not None:
+ if args.snapshot:
+ logging.debug('Skipping inventory validation as it is not applicable'
+ 'to snapshot deployments')
+ elif args.virtual and args.inventory_file is not None:
logging.error("Virtual enabled but inventory file also given")
raise ApexDeployException('You should not specify an inventory file '
'with virtual deployments')
elif args.virtual:
args.inventory_file = os.path.join(APEX_TEMP_DIR,
'inventory-virt.yaml')
- elif os.path.isfile(args.inventory_file) is False:
+ elif not os.path.isfile(args.inventory_file):
logging.error("Specified inventory file does not exist: {}".format(
args.inventory_file))
raise ApexDeployException('Specified inventory file does not exist')
for settings_file in (args.deploy_settings_file,
args.network_settings_file):
+ if settings_file == args.network_settings_file and args.snapshot:
+ continue
if os.path.isfile(settings_file) is False:
logging.error("Specified settings file does not "
"exist: {}".format(settings_file))
deploy_settings = DeploySettings(args.deploy_settings_file)
logging.info("Deploy settings are:\n {}".format(pprint.pformat(
deploy_settings)))
- net_settings = NetworkSettings(args.network_settings_file)
- logging.info("Network settings are:\n {}".format(pprint.pformat(
- net_settings)))
- os_version = deploy_settings['deploy_options']['os_version']
- net_env_file = os.path.join(args.deploy_dir, constants.NET_ENV_FILE)
- net_env = NetworkEnvironment(net_settings, net_env_file,
- os_version=os_version)
- net_env_target = os.path.join(APEX_TEMP_DIR, constants.NET_ENV_FILE)
- utils.dump_yaml(dict(net_env), net_env_target)
-
- # get global deploy params
- ha_enabled = deploy_settings['global_params']['ha_enabled']
- introspect = deploy_settings['global_params'].get('introspect', True)
-
- if args.virtual:
- if args.virt_compute_ram is None:
- compute_ram = args.virt_default_ram
- else:
- compute_ram = args.virt_compute_ram
- if deploy_settings['deploy_options']['sdn_controller'] == \
- 'opendaylight' and args.virt_default_ram < 12:
- control_ram = 12
- logging.warning('RAM per controller is too low. OpenDaylight '
- 'requires at least 12GB per controller.')
- logging.info('Increasing RAM per controller to 12GB')
- elif args.virt_default_ram < 10:
- control_ram = 10
- logging.warning('RAM per controller is too low. nosdn '
- 'requires at least 10GB per controller.')
- logging.info('Increasing RAM per controller to 10GB')
- else:
- control_ram = args.virt_default_ram
- if ha_enabled and args.virt_compute_nodes < 2:
- logging.debug('HA enabled, bumping number of compute nodes to 2')
- args.virt_compute_nodes = 2
- virt_utils.generate_inventory(args.inventory_file, ha_enabled,
- num_computes=args.virt_compute_nodes,
- controller_ram=control_ram * 1024,
- compute_ram=compute_ram * 1024,
- vcpus=args.virt_cpus
- )
- inventory = Inventory(args.inventory_file, ha_enabled, args.virtual)
-
- validate_cross_settings(deploy_settings, net_settings, inventory)
+
+ if not args.snapshot:
+ net_settings = NetworkSettings(args.network_settings_file)
+ logging.info("Network settings are:\n {}".format(pprint.pformat(
+ net_settings)))
+ os_version = deploy_settings['deploy_options']['os_version']
+ net_env_file = os.path.join(args.deploy_dir, constants.NET_ENV_FILE)
+ net_env = NetworkEnvironment(net_settings, net_env_file,
+ os_version=os_version)
+ net_env_target = os.path.join(APEX_TEMP_DIR, constants.NET_ENV_FILE)
+ utils.dump_yaml(dict(net_env), net_env_target)
+
+ # get global deploy params
+ ha_enabled = deploy_settings['global_params']['ha_enabled']
+ introspect = deploy_settings['global_params'].get('introspect', True)
+ net_list = net_settings.enabled_network_list
+ if args.virtual:
+ if args.virt_compute_ram is None:
+ compute_ram = args.virt_default_ram
+ else:
+ compute_ram = args.virt_compute_ram
+ if (deploy_settings['deploy_options']['sdn_controller'] ==
+ 'opendaylight' and args.virt_default_ram < 12):
+ control_ram = 12
+ logging.warning('RAM per controller is too low. OpenDaylight '
+ 'requires at least 12GB per controller.')
+ logging.info('Increasing RAM per controller to 12GB')
+ elif args.virt_default_ram < 10:
+ control_ram = 10
+ logging.warning('RAM per controller is too low. nosdn '
+ 'requires at least 10GB per controller.')
+ logging.info('Increasing RAM per controller to 10GB')
+ else:
+ control_ram = args.virt_default_ram
+ if ha_enabled and args.virt_compute_nodes < 2:
+ logging.debug(
+ 'HA enabled, bumping number of compute nodes to 2')
+ args.virt_compute_nodes = 2
+ virt_utils.generate_inventory(args.inventory_file, ha_enabled,
+ num_computes=args.virt_compute_nodes,
+ controller_ram=control_ram * 1024,
+ compute_ram=compute_ram * 1024,
+ vcpus=args.virt_cpus
+ )
+ inventory = Inventory(args.inventory_file, ha_enabled, args.virtual)
+ logging.info("Inventory is:\n {}".format(pprint.pformat(
+ inventory)))
+
+ validate_cross_settings(deploy_settings, net_settings, inventory)
+ else:
+ # only one network with snapshots
+ net_list = [constants.ADMIN_NETWORK]
+
ds_opts = deploy_settings['deploy_options']
- if args.quickstart:
- deploy_settings_file = os.path.join(APEX_TEMP_DIR,
- 'apex_deploy_settings.yaml')
- utils.dump_yaml(utils.dict_objects_to_str(deploy_settings),
- deploy_settings_file)
- logging.info("File created: {}".format(deploy_settings_file))
- network_settings_file = os.path.join(APEX_TEMP_DIR,
- 'apex_network_settings.yaml')
- utils.dump_yaml(utils.dict_objects_to_str(net_settings),
- network_settings_file)
- logging.info("File created: {}".format(network_settings_file))
- deploy_quickstart(args, deploy_settings_file, network_settings_file,
- args.inventory_file)
+ ansible_args = {
+ 'virsh_enabled_networks': net_list,
+ 'snapshot': args.snapshot
+ }
+ utils.run_ansible(ansible_args,
+ os.path.join(args.lib_dir, constants.ANSIBLE_PATH,
+ 'deploy_dependencies.yml'))
+ if args.snapshot:
+ # Start snapshot Deployment
+ logging.info('Executing Snapshot Deployment...')
+ SnapshotDeployment(deploy_settings=deploy_settings,
+ snap_cache_dir=args.snap_cache,
+ fetch=not args.no_fetch,
+ all_in_one=not bool(args.virt_compute_nodes))
else:
+ # Start Standard TripleO Deployment
+ deployment = ApexDeployment(deploy_settings, args.patches_file,
+ args.deploy_settings_file)
# TODO (trozet): add logic back from:
# Iedb75994d35b5dc1dd5d5ce1a57277c8f3729dfd (FDIO DVR)
- ansible_args = {
- 'virsh_enabled_networks': net_settings.enabled_network_list
- }
- utils.run_ansible(ansible_args,
- os.path.join(args.lib_dir, constants.ANSIBLE_PATH,
- 'deploy_dependencies.yml'))
uc_external = False
if 'external' in net_settings.enabled_network_list:
uc_external = True
shutil.copyfile(uc_fetch_img, uc_image)
# prep undercloud with required packages
uc_builder.add_upstream_packages(uc_image)
+ uc_builder.inject_calipso_installer(APEX_TEMP_DIR, uc_image)
# add patches from upstream to undercloud and overcloud
logging.info('Adding patches to undercloud')
- patches = deploy_settings['global_params']['patches']
+ patches = deployment.determine_patches()
c_builder.add_upstream_patches(patches['undercloud'], uc_image,
APEX_TEMP_DIR, branch)
else:
net_data = False
+ shutil.copyfile(os.path.join(args.deploy_dir, 'build_ovs_nsh.sh'),
+ os.path.join(APEX_TEMP_DIR, 'build_ovs_nsh.sh'))
+
# TODO(trozet): Either fix opnfv env or default to use upstream env
if args.env_file == 'opnfv-environment.yaml':
# Override the env_file if it is defaulted to opnfv
opnfv_env = os.path.join(args.deploy_dir, args.env_file)
oc_deploy.prep_env(deploy_settings, net_settings, inventory,
opnfv_env, net_env_target, APEX_TEMP_DIR)
+ if not args.virtual:
+ oc_deploy.LOOP_DEVICE_SIZE = "50G"
patched_containers = oc_deploy.prep_image(
deploy_settings, net_settings, sdn_image, APEX_TEMP_DIR,
root_pw=root_pw, docker_tag=tag, patches=patches['overcloud'])
docker_playbook = os.path.join(args.lib_dir, constants.ANSIBLE_PATH,
'prepare_overcloud_containers.yml')
if ds_opts['containers']:
- ceph_version = constants.CEPH_VERSION_MAP[ds_opts['os_version']]
- ceph_docker_image = "ceph/daemon:tag-build-master-" \
- "{}-centos-7".format(ceph_version)
logging.info("Preparing Undercloud with Docker containers")
+ sdn_env = oc_deploy.get_docker_sdn_files(ds_opts)
+ sdn_env_files = str()
+ for sdn_file in sdn_env:
+ sdn_env_files += " -e {}".format(sdn_file)
if patched_containers:
oc_builder.archive_docker_patches(APEX_TEMP_DIR)
container_vars = dict()
container_vars['sdn'] = ds_opts['sdn_controller']
container_vars['undercloud_ip'] = undercloud_admin_ip
container_vars['os_version'] = os_version
- container_vars['ceph_docker_image'] = ceph_docker_image
- container_vars['sdn_env_file'] = \
- oc_deploy.get_docker_sdn_file(ds_opts)
+ container_vars['aarch64'] = platform.machine() == 'aarch64'
+ container_vars['sdn_env_file'] = sdn_env_files
try:
utils.run_ansible(container_vars, docker_playbook,
host=undercloud.ip, user='stack',