def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--neutron-conf",
                        required=True,
                        help="File path to the neutron configuration file")
    parser.add_argument("--nuage-conf",
                        required=True,
                        help="File path to the nuage plugin configuration "
                        "file")
    args = parser.parse_args()

    if not nuage_logging.log_file:
        nuage_logging.init_logging(script_name, 'introspect')

    conf_list = []
    for conf_file in (args.neutron_conf, args.nuage_conf):
        if not os.path.isfile(conf_file):
            LOG.user('File "%s" cannot be found.' % conf_file)
            sys.exit(1)
        conf_list.append('--config-file')
        conf_list.append(conf_file)

    config.init(conf_list)
    nuage_config.nuage_register_cfg_opts()

    server = cfg.CONF.RESTPROXY.server
    serverauth = cfg.CONF.RESTPROXY.serverauth
    serverssl = cfg.CONF.RESTPROXY.serverssl
    base_uri = cfg.CONF.RESTPROXY.base_uri
    auth_resource = cfg.CONF.RESTPROXY.auth_resource
    organization = cfg.CONF.RESTPROXY.organization

    try:
        restproxy = RESTProxyServer(server=server,
                                    base_uri=base_uri,
                                    serverssl=serverssl,
                                    serverauth=serverauth,
                                    auth_resource=auth_resource,
                                    organization=organization)

    except Exception as e:
        LOG.user("Error in connecting to VSD: %s", str(e), exc_info=True)
        sys.exit(1)

    try:
        LOG.user("Introspecting the target deployment")
        IntrospectDeployment(restproxy).check()
        LOG.user("Script executed successfully.\n"
                 "Please find the report in {}".format(report_name))

    except Exception as e:
        LOG.user(
            "\n\nThe following error occurred:\n  %(error_msg)s\n"
            "For more information, please find the log file at "
            "%(log_file)s and contact your vendor.", {
                'error_msg': e.message,
                'log_file': nuage_logging.log_file
            },
            exc_info=True)
        sys.exit(1)
示例#2
0
 def __init__(self):
     super(RootNuagePlugin, self).__init__()
     config.nuage_register_cfg_opts()
     self.nuage_callbacks = callback_manager.get_callback_manager()
     self.vsdclient = None  # deferred initialization
     self._l2_plugin = None
     self._l3_plugin = None
示例#3
0
    def test_experimental_feature(self, logger, root_plugin):
        self.set_config_fixture()
        config.nuage_register_cfg_opts()
        conf = self.useFixture(oslo_fixture.Config(cfg.CONF))

        conf.config(group='PLUGIN', experimental_features='experimental_test')
        NuageMechanismDriver().initialize()
        logger.info.assert_called_once_with('Have a nice day.')

        logger.info.reset_mock()
        conf.config(group='PLUGIN', experimental_features='')
        NuageMechanismDriver().initialize()
        logger.info.assert_not_called()
 def __init__(self):
     """initialize the network provision driver."""
     self.context = neutron_context.get_admin_context()
     config.nuage_register_cfg_opts()
     self.init_vsd_client()
# Copyright 2017 Nokia
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from nuage_neutron.plugins.common import config

# Load Nuage configuration
config.nuage_register_cfg_opts()
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--neutron-conf',
                        required=True,
                        help='File path to the neutron configuration file')
    parser.add_argument('--nuage-conf',
                        required=True,
                        help='File path to the nuage plugin configuration '
                             'file')
    args = parser.parse_args()

    if not nuage_logging.log_file:
        nuage_logging.init_logging(SCRIPT_NAME)

    conf_list = []
    for conffile in (args.neutron_conf, args.nuage_conf):
        if not os.path.isfile(conffile):
            LOG.user("File '%s' cannot be found." % conffile)
            sys.exit(1)
        conf_list.append('--config-file')
        conf_list.append(conffile)

    config.init(conf_list)
    nuage_config.nuage_register_cfg_opts()

    server = cfg.CONF.RESTPROXY.server
    serverauth = cfg.CONF.RESTPROXY.serverauth
    serverssl = cfg.CONF.RESTPROXY.serverssl
    base_uri = cfg.CONF.RESTPROXY.base_uri
    auth_resource = cfg.CONF.RESTPROXY.auth_resource
    organization = cfg.CONF.RESTPROXY.organization
    verify_cert = cfg.CONF.RESTPROXY.verify_cert

    try:
        restproxy = RESTProxyServer(server=server,
                                    base_uri=base_uri,
                                    serverssl=serverssl,
                                    serverauth=serverauth,
                                    auth_resource=auth_resource,
                                    organization=organization,
                                    verify_cert=verify_cert)
        restproxy.generate_nuage_auth()
    except Exception as e:
        LOG.user('Error in connecting to VSD: %s', str(e), exc_info=True)
        sys.exit(1)

    try:
        LOG.user('Upgrading resources for 20.10 support\n')

        upgrade = UpgradeTo20Dot10(restproxy)

        with open(REPORT_NAME, 'w') as outfile:
            output = upgrade.upgrade()
            json.dump(output, outfile, indent=4, sort_keys=True)

        LOG.user('The upgrade executed successfully.')

    except Exception as e:
        LOG.user('\n\nThe following error occurred:\n'
                 '  %(error_msg)s\n'
                 'For more information, please find the log file at '
                 '%(log_file)s and contact your vendor.',
                 {'error_msg': str(e),
                  'log_file': nuage_logging.log_file},
                 exc_info=True)
        sys.exit(1)
 def __init__(self):
     super(BaseNuagePlugin, self).__init__()
     config.nuage_register_cfg_opts()
     self._nuageclient_init()
     self.nuage_callbacks = callback_manager.get_callback_manager()
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--neutron-conf',
                        required=True,
                        help='File path to the neutron configuration file')
    parser.add_argument('--nuage-conf',
                        required=True,
                        help='File path to the nuage plugin configuration '
                        'file')
    parser.add_argument('--dry-run',
                        action='store_true',
                        help='Run the upgrade script in dry-run mode')
    args = parser.parse_args()

    if not nuage_logging.log_file:
        nuage_logging.init_logging(SCRIPT_NAME)

    conf_list = []
    for conffile in (args.neutron_conf, args.nuage_conf):
        if not os.path.isfile(conffile):
            LOG.user("File '%s' cannot be found." % conffile)
            sys.exit(1)
        conf_list.append('--config-file')
        conf_list.append(conffile)

    config.init(conf_list)
    nuage_config.nuage_register_cfg_opts()

    server = cfg.CONF.RESTPROXY.server
    serverauth = cfg.CONF.RESTPROXY.serverauth
    serverssl = cfg.CONF.RESTPROXY.serverssl
    base_uri = cfg.CONF.RESTPROXY.base_uri
    auth_resource = cfg.CONF.RESTPROXY.auth_resource
    organization = cfg.CONF.RESTPROXY.organization
    verify_cert = cfg.CONF.RESTPROXY.verify_cert

    if not args.dry_run and 'v6' not in base_uri:
        LOG.user("Can't upgrade because plugin doesn't have v6 API set. "
                 "Please change it ({}) to v6 api (e.g. /nuage/api/v6) "
                 "and run again.".format(base_uri))
        sys.exit(1)

    try:
        restproxy = RESTProxyServer(server=server,
                                    base_uri=base_uri,
                                    serverssl=serverssl,
                                    serverauth=serverauth,
                                    auth_resource=auth_resource,
                                    organization=organization,
                                    verify_cert=verify_cert)
        restproxy.generate_nuage_auth()
    except Exception as e:
        LOG.user('Error in connecting to VSD: %s', str(e), exc_info=True)
        sys.exit(1)

    try:
        if args.dry_run:
            LOG.user('Starting dry-run for 6.0 upgrade\n')
        else:
            LOG.user('Upgrading resources for 6.0 support\n')

        upgrade = UpgradeTo6dot0(restproxy, args.dry_run)

        with open(REPORT_NAME, 'w') as outfile:
            output = upgrade.upgrade()
            json.dump(output, outfile, indent=4, sort_keys=True)

        if args.dry_run:
            if upgrade.has_warnings():
                LOG.user('Dry-run finished with warnings/errors raised.\n'
                         'Please inspect the report {}, as corrective '
                         'actions are needed before running in '
                         'production mode.'.format(REPORT_NAME))
            else:
                LOG.user('Dry-run finished without any warnings raised.\n'
                         'System is good to be upgraded.')
        else:
            if upgrade.has_warnings():
                msg = ("The upgrade finished with warnings raised.\n"
                       "Please inspect the report {}, as corrective "
                       "actions are needed. ").format(REPORT_NAME)
                if upgrade.is_fatal_warn:
                    LOG.user(msg + 'Please re-run after applying those.')
                else:
                    LOG.user(msg + 'No need to re-run the script.')
            else:
                LOG.user('The upgrade executed successfully.')

    except Exception as e:
        LOG.user(
            '\n\nThe following error occurred:\n'
            '  %(error_msg)s\n'
            'For more information, please find the log file at '
            '%(log_file)s and contact your vendor.', {
                'error_msg': str(e),
                'log_file': nuage_logging.log_file
            },
            exc_info=True)
        sys.exit(1)
示例#9
0
 def __init__(self):
     super(BaseNuagePlugin, self).__init__()
     config.nuage_register_cfg_opts()
     self._nuageclient_init()
     self.nuage_callbacks = callback_manager.get_callback_manager()
 def initialize(self):
     LOG.debug('Initializing driver')
     neutron_extensions.append_api_extensions_path(extensions.__path__)
     config.nuage_register_cfg_opts()
     self._nuageclient_init()
     LOG.debug('Initializing complete')