Example #1
0
def parse_arguments():
    parser = ArgParser(prog='python %s' % __file__)
    parser.add_argument('-nf',
                        dest='no_fuel',
                        action='store_true',
                        default=False,
                        help='Do not install Fuel Master (and Node VMs when '
                        'using libvirt)')
    parser.add_argument('-nh',
                        dest='no_health_check',
                        action='store_true',
                        default=False,
                        help='Don\'t run health check after deployment')
    parser.add_argument('-fo',
                        dest='fuel_only',
                        action='store_true',
                        default=False,
                        help='Install Fuel Master only (and Node VMs when '
                        'using libvirt)')
    parser.add_argument('-co',
                        dest='cleanup_only',
                        action='store_true',
                        default=False,
                        help='Cleanup VMs and Virtual Networks according to '
                        'what is defined in DHA')
    parser.add_argument('-c',
                        dest='cleanup',
                        action='store_true',
                        default=False,
                        help='Cleanup after deploy')
    if {'-iso', '-dea', '-dha', '-h'}.intersection(sys.argv):
        parser.add_argument('-iso',
                            dest='iso_file',
                            action='store',
                            nargs='?',
                            default='%s/OPNFV.iso' % CWD,
                            help='ISO File [default: OPNFV.iso]')
        parser.add_argument('-dea',
                            dest='dea_file',
                            action='store',
                            nargs='?',
                            default='%s/dea.yaml' % CWD,
                            help='Deployment Environment Adapter: dea.yaml')
        parser.add_argument('-dha',
                            dest='dha_file',
                            action='store',
                            nargs='?',
                            default='%s/dha.yaml' % CWD,
                            help='Deployment Hardware Adapter: dha.yaml')
    else:
        parser.add_argument('iso_file',
                            action='store',
                            nargs='?',
                            default='%s/OPNFV.iso' % CWD,
                            help='ISO File [default: OPNFV.iso]')
        parser.add_argument('dea_file',
                            action='store',
                            nargs='?',
                            default='%s/dea.yaml' % CWD,
                            help='Deployment Environment Adapter: dea.yaml')
        parser.add_argument('dha_file',
                            action='store',
                            nargs='?',
                            default='%s/dha.yaml' % CWD,
                            help='Deployment Hardware Adapter: dha.yaml')
    parser.add_argument('-s',
                        dest='storage_dir',
                        action='store',
                        default='%s/images' % CWD,
                        help='Storage Directory [default: images]')
    parser.add_argument('-b',
                        dest='pxe_bridge',
                        action='append',
                        default=[],
                        help='Linux Bridge for booting up the Fuel Master VM '
                        '[default: pxebr]')
    parser.add_argument('-p',
                        dest='fuel_plugins_dir',
                        action='store',
                        help='Fuel Plugins directory')
    parser.add_argument('-pc',
                        dest='fuel_plugins_conf_dir',
                        action='store',
                        help='Fuel Plugins Configuration directory')
    parser.add_argument('-np',
                        dest='no_plugins',
                        action='store_true',
                        default=False,
                        help='Do not install Fuel Plugins')
    parser.add_argument('-dt',
                        dest='deploy_timeout',
                        action='store',
                        default=240,
                        help='Deployment timeout (in minutes) '
                        '[default: 240]')
    parser.add_argument('-nde',
                        dest='no_deploy_environment',
                        action='store_true',
                        default=False,
                        help=('Do not launch environment deployment'))
    parser.add_argument('-log',
                        dest='deploy_log',
                        action='store',
                        default='../ci/.',
                        help=('Path and name of the deployment log archive'))

    args = parser.parse_args()
    log(args)

    if not args.pxe_bridge:
        args.pxe_bridge = ['pxebr']

    check_file_exists(args.dha_file)

    check_dir_exists(os.path.dirname(args.deploy_log))

    if not args.cleanup_only:
        check_file_exists(args.dea_file)
        check_fuel_plugins_dir(args.fuel_plugins_dir)

    iso_abs_path = os.path.abspath(args.iso_file)
    if not args.no_fuel and not args.cleanup_only:
        log('Using OPNFV ISO file: %s' % iso_abs_path)
        check_file_exists(iso_abs_path)
        log('Using image directory: %s' % args.storage_dir)
        create_dir_if_not_exists(args.storage_dir)
        for bridge in args.pxe_bridge:
            check_bridge(bridge, args.dha_file)

    kwargs = {
        'no_fuel': args.no_fuel,
        'fuel_only': args.fuel_only,
        'no_health_check': args.no_health_check,
        'cleanup_only': args.cleanup_only,
        'cleanup': args.cleanup,
        'storage_dir': args.storage_dir,
        'pxe_bridge': args.pxe_bridge,
        'iso_file': iso_abs_path,
        'dea_file': args.dea_file,
        'dha_file': args.dha_file,
        'fuel_plugins_dir': args.fuel_plugins_dir,
        'fuel_plugins_conf_dir': args.fuel_plugins_conf_dir,
        'no_plugins': args.no_plugins,
        'deploy_timeout': args.deploy_timeout,
        'no_deploy_environment': args.no_deploy_environment,
        'deploy_log': args.deploy_log
    }
    return kwargs
Example #2
0
 def setup_environment(self):
     check_dir_exists(self.network_dir)
     self.cleanup_environment()
     self.create_networks()
     self.create_vms()
     self.start_vms()
 def setup_environment(self):
     check_dir_exists(self.network_dir)
     self.cleanup_environment()
     self.create_networks()
     self.create_vms()
     self.start_vms()