Ejemplo n.º 1
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    # add neutron plugin requirements. nova-c-c only needs the neutron-server
    # associated with configs, not the plugin agent.
    plugin = config('neutron-plugin')
    conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
    ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or [])
    services = neutron_plugin_attribute(plugin, 'server_services', 'neutron')
    resource_map[conf] = {}
    resource_map[conf]['services'] = services
    resource_map[conf]['contexts'] = ctxts
    resource_map[conf]['contexts'].append(
        neutron_api_context.NeutronCCContext())

    # update for postgres
    resource_map[conf]['contexts'].append(
        context.PostgresqlDBContext(database=config('database')))

    return resource_map
Ejemplo n.º 2
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if relation_ids('nova-volume-service'):
        # if we have a relation to a nova-volume service, we're
        # also managing the nova-volume API endpoint (legacy)
        resource_map['/etc/nova/nova.conf']['services'].append(
            'nova-api-os-volume')

    net_manager = network_manager()

    # pop out irrelevant resources from the OrderedDict (easier than adding
    # them late)
    if net_manager != 'quantum':
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
         if 'quantum' in k]
    if net_manager != 'neutron':
        [resource_map.pop(k) for k in list(resource_map.iterkeys())
         if 'neutron' in k]

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    # add neutron plugin requirements. nova-c-c only needs the neutron-server
    # associated with configs, not the plugin agent.
    if net_manager in ['quantum', 'neutron']:
        plugin = neutron_plugin()
        if plugin:
            conf = neutron_plugin_attribute(plugin, 'config', net_manager)
            ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
                     or [])
            services = neutron_plugin_attribute(plugin, 'server_services',
                                                net_manager)
            resource_map[conf] = {}
            resource_map[conf]['services'] = services
            resource_map[conf]['contexts'] = ctxts
            resource_map[conf]['contexts'].append(
                nova_cc_context.NeutronCCContext())

    # nova-conductor for releases >= G.
    if os_release('nova-common') not in ['essex', 'folsom']:
        resource_map['/etc/nova/nova.conf']['services'] += ['nova-conductor']

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware',
                                                   service='nova',
                                                   config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and 'services' in vmware_ctxt:
        for s in vmware_ctxt['services']:
            if s not in resource_map[NOVA_CONF]['services']:
                resource_map[NOVA_CONF]['services'].append(s)
    return resource_map
Ejemplo n.º 3
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    # TODO: Cache this on first call?
    if config('virt-type').lower() == 'lxd':
        resource_map = deepcopy(BASE_RESOURCE_MAP)
    else:
        resource_map = deepcopy(LIBVIRT_RESOURCE_MAP)
    net_manager = network_manager()
    plugin = neutron_plugin()

    # Network manager gets set late by the cloud-compute interface.
    # FlatDHCPManager only requires some extra packages.
    if (net_manager in ['flatmanager', 'flatdhcpmanager'] and
            config('multi-host').lower() == 'yes'):
        resource_map[NOVA_CONF]['services'].extend(
            ['nova-api', 'nova-network']
        )

    # Neutron/quantum requires additional contexts, as well as new resources
    # depending on the plugin used.
    # NOTE(james-page): only required for ovs plugin right now
    if net_manager in ['neutron', 'quantum']:
        # This stanza supports the legacy case of ovs supported within
        # compute charm code (now moved to neutron-openvswitch subordinate)
        if manage_ovs():
            if net_manager == 'quantum':
                nm_rsc = QUANTUM_RESOURCES
            if net_manager == 'neutron':
                nm_rsc = NEUTRON_RESOURCES
            resource_map.update(nm_rsc)

            conf = neutron_plugin_attribute(plugin, 'config', net_manager)
            svcs = neutron_plugin_attribute(plugin, 'services', net_manager)
            ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
                     or [])
            resource_map[conf] = {}
            resource_map[conf]['services'] = svcs
            resource_map[conf]['contexts'] = ctxts
            resource_map[conf]['contexts'].append(NeutronComputeContext())

            # associate the plugin agent with main network manager config(s)
            [resource_map[nmc]['services'].extend(svcs) for nmc in nm_rsc]

        resource_map[NOVA_CONF]['contexts'].append(NeutronComputeContext())

    if relation_ids('ceph'):
        CEPH_RESOURCES[ceph_config_file()] = {
            'contexts': [NovaComputeCephContext()],
            'services': ['nova-compute']
        }
        resource_map.update(CEPH_RESOURCES)

    if enable_nova_metadata():
        resource_map[NOVA_CONF]['services'].append('nova-api-metadata')
    return resource_map
Ejemplo n.º 4
0
 def pg_ctxt(self):
     driver = neutron_plugin_attribute(self.plugin, 'driver',
                                       self.network_manager)
     config = neutron_plugin_attribute(self.plugin, 'config',
                                       self.network_manager)
     ovs_ctxt = {'core_plugin': driver,
                 'neutron_plugin': 'plumgrid',
                 'neutron_security_groups': self.neutron_security_groups,
                 'local_ip': unit_private_ip(),
                 'config': config}
     return ovs_ctxt
def set_neutron_relation():
    settings = {
        'neutron-plugin':
        'vsp',
        'core-plugin':
        neutron_plugin_attribute('vsp', 'driver', 'neutron'),
        'neutron-plugin-config':
        neutron_plugin_attribute('vsp', 'config', 'neutron'),
        'service-plugins':
        ' ',
    }
    relation_set(relation_settings=settings)
Ejemplo n.º 6
0
 def pg_ctxt(self):
     driver = neutron_plugin_attribute(self.plugin, 'driver',
                                       self.network_manager)
     config = neutron_plugin_attribute(self.plugin, 'config',
                                       self.network_manager)
     ovs_ctxt = {
         'core_plugin': driver,
         'neutron_plugin': 'plumgrid',
         'neutron_security_groups': self.neutron_security_groups,
         'local_ip': unit_private_ip(),
         'config': config
     }
     return ovs_ctxt
def resource_map():
    """
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    """
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if relation_ids("nova-volume-service"):
        # if we have a relation to a nova-volume service, we're
        # also managing the nova-volume API endpoint (legacy)
        resource_map["/etc/nova/nova.conf"]["services"].append("nova-api-os-volume")

    net_manager = network_manager()

    # pop out irrelevant resources from the OrderedDict (easier than adding
    # them late)
    if net_manager != "quantum":
        [resource_map.pop(k) for k in list(resource_map.iterkeys()) if "quantum" in k]
    if net_manager != "neutron":
        [resource_map.pop(k) for k in list(resource_map.iterkeys()) if "neutron" in k]

    if os.path.exists("/etc/apache2/conf-available"):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    # add neutron plugin requirements. nova-c-c only needs the neutron-server
    # associated with configs, not the plugin agent.
    if net_manager in ["quantum", "neutron"]:
        plugin = neutron_plugin()
        if plugin:
            conf = neutron_plugin_attribute(plugin, "config", net_manager)
            ctxts = neutron_plugin_attribute(plugin, "contexts", net_manager) or []
            services = neutron_plugin_attribute(plugin, "server_services", net_manager)
            resource_map[conf] = {}
            resource_map[conf]["services"] = services
            resource_map[conf]["contexts"] = ctxts
            resource_map[conf]["contexts"].append(nova_cc_context.NeutronCCContext())

    # nova-conductor for releases >= G.
    if os_release("nova-common") not in ["essex", "folsom"]:
        resource_map["/etc/nova/nova.conf"]["services"] += ["nova-conductor"]

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface="nova-vmware", service="nova", config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and "services" in vmware_ctxt:
        for s in vmware_ctxt["services"]:
            if s not in resource_map[NOVA_CONF]["services"]:
                resource_map[NOVA_CONF]["services"].append(s)
    return resource_map
Ejemplo n.º 8
0
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if CompareOpenStackReleases(release) >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka'
                and config('enable-sriov')):
            resource_map[ML2_SRIOV_INI] = {}
            resource_map[ML2_SRIOV_INI]['services'] = services
            resource_map[ML2_SRIOV_INI]['contexts'] = []
        if (config('enable-arista')):
            resource_map[NEUTRON_DEFAULT]['contexts'] = \
                [neutron_api_context.NeutronApiSDNConfigFileContext()]
    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext())
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    if enable_memcache(release=release):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']
        }

    return resource_map
Ejemplo n.º 9
0
def set_neutron_relation():
    settings = {
        'neutron-plugin':
        'plumgrid',
        'core-plugin':
        neutron_plugin_attribute('plumgrid', 'driver', 'neutron'),
        'neutron-plugin-config':
        neutron_plugin_attribute('plumgrid', 'config', 'neutron'),
        'service-plugins':
        ' ',
        'quota-driver':
        'neutron.db.quota_db.DbQuotaDriver',
    }

    relation_set(relation_settings=settings)
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if CompareOpenStackReleases(release) >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
                 [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        if ('kilo' <= CompareOpenStackReleases(release) <= 'mitaka' and
                config('enable-sriov')):
            resource_map[ML2_SRIOV_INI] = {}
            resource_map[ML2_SRIOV_INI]['services'] = services
            resource_map[ML2_SRIOV_INI]['contexts'] = []
    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext()
        )
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    if enable_memcache(release=release):
        resource_map[MEMCACHED_CONF] = {
            'contexts': [context.MemcacheContext()],
            'services': ['memcached']}

    return resource_map
Ejemplo n.º 11
0
def determine_packages():
    pkgs = []
    py3_pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
        py3_pkgs.append('python3-neutron-fwaas')
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    cmp_release = CompareOpenStackReleases(
        os_release('neutron-common', base='icehouse',
                   reset_cache=True))
    if cmp_release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    if enable_sriov():
        if cmp_release >= 'mitaka':
            pkgs.append('neutron-sriov-agent')
        else:
            pkgs.append('neutron-plugin-sriov-agent')

    if cmp_release >= 'rocky':
        pkgs = [p for p in pkgs if not p.startswith('python-')]
        pkgs.extend(PY3_PACKAGES)
        pkgs.extend(py3_pkgs)

    return pkgs
Ejemplo n.º 12
0
def determine_packages(source=None):
    # currently all packages match service names
    packages = [] + BASE_PACKAGES

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages', 'neutron')
            packages.extend(pkgs)

    release = get_os_codename_install_source(source)

    if CompareOpenStackReleases(release) >= 'kilo':
        packages.extend(KILO_PACKAGES)
    if CompareOpenStackReleases(release) >= 'ocata':
        packages.append('python-neutron-dynamic-routing')
    if CompareOpenStackReleases(release) >= 'pike':
        packages.remove('python-neutron-vpnaas')

    if release == 'kilo' or CompareOpenStackReleases(release) >= 'mitaka':
        packages.append('python-networking-hyperv')

    if config('neutron-plugin') == 'vsp':
        nuage_pkgs = config('nuage-packages').split()
        packages += nuage_pkgs

    packages.extend(token_cache_pkgs(release=release))
    return list(set(packages))
def determine_packages():
    pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    cmp_release = CompareOpenStackReleases(
        os_release('neutron-common', base='icehouse'))
    if cmp_release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    if enable_sriov():
        if cmp_release >= 'mitaka':
            pkgs.append('neutron-sriov-agent')
        else:
            pkgs.append('neutron-plugin-sriov-agent')

    return pkgs
def determine_packages():
    pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    if git_install_requested():
        pkgs.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in pkgs:
                pkgs.remove(p)

    release = os_release('neutron-common', base='icehouse')
    if release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    return pkgs
Ejemplo n.º 15
0
def determine_packages(source=None):
    # currently all packages match service names
    packages = [] + BASE_PACKAGES

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages', 'neutron')
            packages.extend(pkgs)

    release = get_os_codename_install_source(source)

    if release >= 'kilo':
        packages.extend(KILO_PACKAGES)

    if release == 'kilo' or release >= 'mitaka':
        packages.append('python-networking-hyperv')

    if config('neutron-plugin') == 'vsp':
        nuage_pkgs = config('nuage-packages').split()
        packages += nuage_pkgs

    if git_install_requested():
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        packages = list(set(packages))
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)
        if release >= 'kilo':
            for p in GIT_PACKAGE_BLACKLIST_KILO:
                packages.remove(p)

    return list(set(packages))
def nuage_vsp_juno_neutron_migration():
    log('Nuage VSP with Juno Relase')
    nuage_migration_db_path = '/usr/lib/python2.7/dist-packages/'\
                              'neutron/db/migration/nuage'
    nuage_migrate_hybrid_file_path = os.path.join(
        nuage_migration_db_path, 'migrate_hybrid_juno.py')
    nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
                                                 'config', 'neutron')
    if os.path.exists(nuage_migration_db_path):
        if os.path.exists(nuage_migrate_hybrid_file_path):
            if os.path.exists(nuage_config_file):
                log('Running Migartion Script for Juno Release')
                cmd = 'sudo python ' + nuage_migrate_hybrid_file_path + \
                      ' --config-file ' + nuage_config_file + \
                      ' --config-file ' + NEUTRON_CONF
                log(cmd)
                subprocess.check_output(cmd, shell=True)
            else:
                e = nuage_config_file+' doesnot exist'
                log(e)
                raise Exception(e)
        else:
            e = nuage_migrate_hybrid_file_path+' doesnot exists'
            log(e)
            raise Exception(e)
    else:
        e = nuage_migration_db_path+' doesnot exists'
        log(e)
        raise Exception(e)
Ejemplo n.º 17
0
def determine_packages(source=None):
    # currently all packages match service names
    packages = [] + BASE_PACKAGES

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages',
                                            'neutron')
            packages.extend(pkgs)

    if get_os_codename_install_source(source) >= 'kilo':
        packages.extend(KILO_PACKAGES)

    if config('neutron-plugin') == 'vsp':
        nuage_pkgs = config('nuage-packages').split()
        packages += nuage_pkgs

    if git_install_requested():
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        packages = list(set(packages))
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)
        if get_os_codename_install_source(source) >= 'kilo':
            for p in GIT_PACKAGE_BLACKLIST_KILO:
                packages.remove(p)

    return list(set(packages))
Ejemplo n.º 18
0
def determine_packages(source=None):
    # currently all packages match service names
    packages = [] + BASE_PACKAGES

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages', 'neutron')
            packages.extend(pkgs)

    if get_os_codename_install_source(source) >= 'kilo':
        packages.extend(KILO_PACKAGES)

    if git_install_requested():
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        packages = list(set(packages))
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)
        if get_os_codename_install_source(source) >= 'kilo':
            for p in GIT_PACKAGE_BLACKLIST_KILO:
                packages.remove(p)

    return list(set(packages))
Ejemplo n.º 19
0
def determine_packages():
    pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    if git_install_requested():
        pkgs.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in pkgs:
                pkgs.remove(p)

    cmp_release = CompareOpenStackReleases(
        os_release('neutron-common', base='icehouse'))
    if cmp_release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    if enable_sriov_agent():
        pkgs.append('neutron-sriov-agent')

    return pkgs
def determine_packages():
    packages = [] + BASE_PACKAGES

    net_manager = network_manager()
    if (net_manager in ['flatmanager', 'flatdhcpmanager'] and
            config('multi-host').lower() == 'yes'):
        packages.extend(['nova-api', 'nova-network'])
    elif net_manager == 'neutron' and neutron_plugin_legacy_mode():
        plugin = neutron_plugin()
        pkg_lists = neutron_plugin_attribute(plugin, 'packages', net_manager)
        for pkg_list in pkg_lists:
            packages.extend(pkg_list)

    if relation_ids('ceph'):
        packages.append('ceph-common')

    virt_type = config('virt-type')
    try:
        packages.extend(VIRT_TYPES[virt_type])
    except KeyError:
        log('Unsupported virt-type configured: %s' % virt_type)
        raise
    if enable_nova_metadata():
        packages.append('nova-api-metadata')

    if git_install_requested():
        packages = list(set(packages))
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)

    return packages
Ejemplo n.º 21
0
def nuage_vsp_juno_neutron_migration():
    log('Nuage VSP with Juno Relase')
    nuage_migration_db_path = '/usr/lib/python2.7/dist-packages/'\
                              'neutron/db/migration/nuage'
    nuage_migrate_hybrid_file_path = os.path.join(
        nuage_migration_db_path, 'migrate_hybrid_juno.py')
    nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
                                                 'config', 'neutron')
    if os.path.exists(nuage_migration_db_path):
        if os.path.exists(nuage_migrate_hybrid_file_path):
            if os.path.exists(nuage_config_file):
                log('Running Migartion Script for Juno Release')
                cmd = 'sudo python ' + nuage_migrate_hybrid_file_path + \
                      ' --config-file ' + nuage_config_file + \
                      ' --config-file ' + NEUTRON_CONF
                log(cmd)
                subprocess.check_output(cmd, shell=True)
            else:
                e = nuage_config_file+' doesnot exist'
                log(e)
                raise Exception(e)
        else:
            e = nuage_migrate_hybrid_file_path+' doesnot exists'
            log(e)
            raise Exception(e)
    else:
        e = nuage_migration_db_path+' doesnot exists'
        log(e)
        raise Exception(e)
Ejemplo n.º 22
0
def migrate_neutron_database(upgrade=False):
    '''Initializes a new database or upgrades an existing database.'''

    if not upgrade and is_db_initialised():
        log("Database is already initialised.", level=DEBUG)
        return

    log('Migrating the neutron database.')
    if (os_release('neutron-server') == 'juno'
            and config('neutron-plugin') == 'vsp'):
        nuage_vsp_juno_neutron_migration()
    else:
        plugin = config('neutron-plugin')
        cmd = [
            'neutron-db-manage', '--config-file', NEUTRON_CONF,
            '--config-file',
            neutron_plugin_attribute(plugin, 'config',
                                     'neutron'), 'upgrade', 'head'
        ]
        subprocess.check_output(cmd)

    cluster_rids = relation_ids('cluster')
    if cluster_rids:
        # Notify peers so that services get restarted
        log("Notifying peer(s) that db is initialised and restarting services",
            level=DEBUG)
        for r_id in cluster_rids:
            if not is_unit_paused_set():
                service_restart('neutron-server')

            # Notify peers that tey should also restart their services
            shared_db_rel_id = (relation_ids('shared-db') or [None])[0]
            id = "{}-{}-{}".format(local_unit(), shared_db_rel_id,
                                   uuid.uuid4())
            relation_set(relation_id=r_id, **{NEUTRON_DB_INIT_RKEY: id})
Ejemplo n.º 23
0
    def n1kv_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, 'driver',
                                          self.network_manager)
        n1kv_config = neutron_plugin_attribute(self.plugin, 'config',
                                          self.network_manager)
        n1kv_ctxt = {
            'core_plugin': driver,
            'neutron_plugin': 'n1kv',
            'neutron_security_groups': self.neutron_security_groups,
            'local_ip': unit_private_ip(),
            'config': n1kv_config,
            'vsm_ip': config('n1kv-vsm-ip'),
            'vsm_username': config('n1kv-vsm-username'),
            'vsm_password': config('n1kv-vsm-password'),
        }

        return n1kv_ctxt
def determine_packages():
    # currently all packages match service names
    packages = [] + BASE_PACKAGES
    for k, v in resource_map().iteritems():
        packages.extend(v["services"])
    if network_manager() in ["neutron", "quantum"]:
        pkgs = neutron_plugin_attribute(neutron_plugin(), "server_packages", network_manager())
        packages.extend(pkgs)
    return list(set(packages))
def db_changed():
    if 'shared-db' not in CONFIGS.complete_contexts():
        log('shared-db relation incomplete. Peer not ready?')
        return
    CONFIGS.write(NOVA_CONF)
    nm = network_manager()
    plugin = neutron_plugin()
    if nm in ['quantum', 'neutron'] and plugin == 'ovs':
        CONFIGS.write(neutron_plugin_attribute(plugin, 'config', nm))
Ejemplo n.º 26
0
def stamp_neutron_database(release):
    '''Stamp the database with the current release before upgrade.'''
    log('Stamping the neutron database with release %s.' % release)
    plugin = config('neutron-plugin')
    cmd = [
        'neutron-db-manage', '--config-file', NEUTRON_CONF, '--config-file',
        neutron_plugin_attribute(plugin, 'config', 'neutron'), 'stamp', release
    ]
    subprocess.check_output(cmd)
Ejemplo n.º 27
0
def determine_packages():
    # currently all packages match service names
    packages = [] + BASE_PACKAGES
    for v in resource_map().values():
        packages.extend(v['services'])
        pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                        'server_packages', 'neutron')
        packages.extend(pkgs)
    return list(set(packages))
Ejemplo n.º 28
0
    def n1kv_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, 'driver',
                                          self.network_manager)
        n1kv_config = neutron_plugin_attribute(self.plugin, 'config',
                                               self.network_manager)
        n1kv_ctxt = {
            'core_plugin': driver,
            'neutron_plugin': 'n1kv',
            'neutron_security_groups': self.neutron_security_groups,
            'local_ip': unit_private_ip(),
            'config': n1kv_config,
            'vsm_ip': config('n1kv-vsm-ip'),
            'vsm_username': config('n1kv-vsm-username'),
            'vsm_password': config('n1kv-vsm-password'),
            'restrict_policy_profiles': config(
                'n1kv_restrict_policy_profiles'),
        }

        return n1kv_ctxt
Ejemplo n.º 29
0
def migrate_neutron_database():
    '''Initializes a new database or upgrades an existing database.'''
    log('Migrating the neutron database.')
    plugin = config('neutron-plugin')
    cmd = [
        'neutron-db-manage', '--config-file', NEUTRON_CONF, '--config-file',
        neutron_plugin_attribute(plugin, 'config', 'neutron'), 'upgrade',
        'head'
    ]
    subprocess.check_output(cmd)
def neutron_db_manage(actions):
    net_manager = network_manager()
    if net_manager == 'neutron':
        plugin = neutron_plugin()
        conf = neutron_plugin_attribute(plugin, 'config', net_manager)
        subprocess.check_call([
            NEUTRON_DB_MANAGE,
            '--config-file=/etc/{mgr}/{mgr}.conf'.format(mgr=net_manager),
            '--config-file={}'.format(conf)] + actions
        )
Ejemplo n.º 31
0
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if release >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
                 [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        # update for postgres
        resource_map[conf]['contexts'].append(
            context.PostgresqlDBContext(database=config('database')))

    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext()
        )
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    return resource_map
Ejemplo n.º 32
0
def resource_map(release=None):
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    release = release or os_release('neutron-common')

    resource_map = deepcopy(BASE_RESOURCE_MAP)
    if release >= 'liberty':
        resource_map.update(LIBERTY_RESOURCE_MAP)

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    if manage_plugin():
        # add neutron plugin requirements. nova-c-c only needs the
        # neutron-server associated with configs, not the plugin agent.
        plugin = config('neutron-plugin')
        conf = neutron_plugin_attribute(plugin, 'config', 'neutron')
        ctxts = (neutron_plugin_attribute(plugin, 'contexts', 'neutron') or
                 [])
        services = neutron_plugin_attribute(plugin, 'server_services',
                                            'neutron')
        resource_map[conf] = {}
        resource_map[conf]['services'] = services
        resource_map[conf]['contexts'] = ctxts
        resource_map[conf]['contexts'].append(
            neutron_api_context.NeutronCCContext())

        # update for postgres
        resource_map[conf]['contexts'].append(
            context.PostgresqlDBContext(database=config('database')))

    else:
        resource_map[NEUTRON_CONF]['contexts'].append(
            neutron_api_context.NeutronApiSDNContext()
        )
        resource_map[NEUTRON_DEFAULT]['contexts'] = \
            [neutron_api_context.NeutronApiSDNConfigFileContext()]
    return resource_map
    def ovs_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, "driver", self.network_manager)

        ovs_ctxt = {
            "core_plugin": driver,
            "neutron_plugin": "ovs",
            "neutron_security_groups": self.neutron_security_groups,
            "local_ip": unit_private_ip(),
        }

        return ovs_ctxt
Ejemplo n.º 34
0
def stamp_neutron_database(release):
    '''Stamp the database with the current release before upgrade.'''
    log('Stamping the neutron database with release %s.' % release)
    plugin = config('neutron-plugin')
    cmd = ['neutron-db-manage',
           '--config-file', NEUTRON_CONF,
           '--config-file', neutron_plugin_attribute(plugin,
                                                     'config',
                                                     'neutron'),
           'stamp',
           release]
    subprocess.check_output(cmd)
Ejemplo n.º 35
0
    def n1kv_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, 'driver',
                                          self.network_manager)

        n1kv_ctxt = {
            'core_plugin': driver,
            'neutron_plugin': 'n1kv',
            'neutron_security_groups': self.neutron_security_groups,
            'local_ip': unit_private_ip(),
        }

        return n1kv_ctxt
Ejemplo n.º 36
0
def migrate_neutron_database():
    '''Initializes a new database or upgrades an existing database.'''
    log('Migrating the neutron database.')
    plugin = config('neutron-plugin')
    cmd = ['neutron-db-manage',
           '--config-file', NEUTRON_CONF,
           '--config-file', neutron_plugin_attribute(plugin,
                                                     'config',
                                                     'neutron'),
           'upgrade',
           'head']
    subprocess.check_output(cmd)
Ejemplo n.º 37
0
def neutron_db_manage(actions):
    net_manager = network_manager()
    if net_manager in ['neutron', 'quantum']:
        plugin = neutron_plugin()
        conf = neutron_plugin_attribute(plugin, 'config', net_manager)
        if net_manager == 'quantum':
            cmd = QUANTUM_DB_MANAGE
        else:
            cmd = NEUTRON_DB_MANAGE
        subprocess.check_call([
            cmd, '--config-file=/etc/{mgr}/{mgr}.conf'.format(mgr=net_manager),
            '--config-file={}'.format(conf)] + actions
        )
Ejemplo n.º 38
0
def neutron_db_manage(actions):
    net_manager = network_manager()
    if net_manager in ['neutron', 'quantum']:
        plugin = neutron_plugin()
        conf = neutron_plugin_attribute(plugin, 'config', net_manager)
        if net_manager == 'quantum':
            cmd = QUANTUM_DB_MANAGE
        else:
            cmd = NEUTRON_DB_MANAGE
        subprocess.check_call([
            cmd, '--config-file=/etc/{mgr}/{mgr}.conf'.format(
                mgr=net_manager), '--config-file={}'.format(conf)
        ] + actions)
Ejemplo n.º 39
0
    def n1kv_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, 'driver',
                                          self.network_manager)
        n1kv_config = neutron_plugin_attribute(self.plugin, 'config',
                                               self.network_manager)
        n1kv_user_config_flags = config('n1kv-config-flags')
        restrict_policy_profiles = config('n1kv-restrict-policy-profiles')
        n1kv_ctxt = {'core_plugin': driver,
                     'neutron_plugin': 'n1kv',
                     'neutron_security_groups': self.neutron_security_groups,
                     'local_ip': unit_private_ip(),
                     'config': n1kv_config,
                     'vsm_ip': config('n1kv-vsm-ip'),
                     'vsm_username': config('n1kv-vsm-username'),
                     'vsm_password': config('n1kv-vsm-password'),
                     'restrict_policy_profiles': restrict_policy_profiles}

        if n1kv_user_config_flags:
            flags = config_flags_parser(n1kv_user_config_flags)
            n1kv_ctxt['user_config_flags'] = flags

        return n1kv_ctxt
Ejemplo n.º 40
0
def vsd_changed(relation_id=None, remote_unit=None):
    if config('neutron-plugin') == 'vsp':
        vsd_ip_address = relation_get('vsd-ip-address')
        if not vsd_ip_address:
            return
        vsd_address = '{}:8443'.format(vsd_ip_address)
        if os_release('neutron-server') >= 'kilo':
            cms_id = relation_get('nuage-cms-id')
            log("nuage-vsd-api-relation-changed : cms_id:{}".format(cms_id))
        nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
                                                     'config', 'neutron')
        log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
        log('vsd-rest-api-relation-changed:{}'.format(nuage_config_file))

        CONFIGS.write(nuage_config_file)
Ejemplo n.º 41
0
def vsd_changed(relation_id=None, remote_unit=None):
    if config('neutron-plugin') == 'vsp':
        vsd_ip_address = relation_get('vsd-ip-address')
        if not vsd_ip_address:
            return
        vsd_address = '{}:8443'.format(vsd_ip_address)
        if os_release('neutron-server') >= 'kilo':
            cms_id = relation_get('nuage-cms-id')
            log("nuage-vsd-api-relation-changed : cms_id:{}".format(cms_id))
        nuage_config_file = neutron_plugin_attribute(config('neutron-plugin'),
                                                     'config', 'neutron')
        log('vsd-rest-api-relation-changed: ip address:{}'.format(vsd_address))
        log('vsd-rest-api-relation-changed:{}'.format(nuage_config_file))

        CONFIGS.write(nuage_config_file)
Ejemplo n.º 42
0
    def n1kv_ctxt(self):
        driver = neutron_plugin_attribute(self.plugin, 'driver',
                                          self.network_manager)
        n1kv_config = neutron_plugin_attribute(self.plugin, 'config',
                                               self.network_manager)
        n1kv_user_config_flags = config('n1kv-config-flags')
        restrict_policy_profiles = config('n1kv-restrict-policy-profiles')
        n1kv_ctxt = {
            'core_plugin': driver,
            'neutron_plugin': 'n1kv',
            'neutron_security_groups': self.neutron_security_groups,
            'local_ip': unit_private_ip(),
            'config': n1kv_config,
            'vsm_ip': config('n1kv-vsm-ip'),
            'vsm_username': config('n1kv-vsm-username'),
            'vsm_password': config('n1kv-vsm-password'),
            'restrict_policy_profiles': restrict_policy_profiles
        }

        if n1kv_user_config_flags:
            flags = config_flags_parser(n1kv_user_config_flags)
            n1kv_ctxt['user_config_flags'] = flags

        return n1kv_ctxt
Ejemplo n.º 43
0
def migrate_neutron_database():
    '''Initializes a new database or upgrades an existing database.'''
    log('Migrating the neutron database.')
    if (os_release('neutron-server') == 'juno'
            and config('neutron-plugin') == 'vsp'):
        nuage_vsp_juno_neutron_migration()
    else:
        plugin = config('neutron-plugin')
        cmd = [
            'neutron-db-manage', '--config-file', NEUTRON_CONF,
            '--config-file',
            neutron_plugin_attribute(plugin, 'config',
                                     'neutron'), 'upgrade', 'head'
        ]
        subprocess.check_output(cmd)
Ejemplo n.º 44
0
def migrate_neutron_database():
    '''Initializes a new database or upgrades an existing database.'''
    log('Migrating the neutron database.')
    if(os_release('neutron-server') == 'juno' and
       config('neutron-plugin') == 'vsp'):
        nuage_vsp_juno_neutron_migration()
    else:
        plugin = config('neutron-plugin')
        cmd = ['neutron-db-manage',
               '--config-file', NEUTRON_CONF,
               '--config-file', neutron_plugin_attribute(plugin,
                                                         'config',
                                                         'neutron'),
               'upgrade',
               'head']
        subprocess.check_output(cmd)
Ejemplo n.º 45
0
def db_changed():
    if 'shared-db' not in CONFIGS.complete_contexts():
        log('shared-db relation incomplete. Peer not ready?')
        return
    CONFIGS.write(NOVA_CONF)

    if network_manager() in ['neutron', 'quantum']:
        plugin = neutron_plugin()
        # DB config might have been moved to main neutron.conf in H?
        CONFIGS.write(neutron_plugin_attribute(plugin, 'config'))

    if eligible_leader(CLUSTER_RES):
        migrate_database()
        log('Triggering remote cloud-compute restarts.')
        [compute_joined(rid=rid, remote_restart=True)
         for rid in relation_ids('cloud-compute')]
def determine_packages(source=None, openstack_release=None):
    # currently all packages match service names
    if openstack_release:
        release = openstack_release
    else:
        release = get_os_codename_install_source(source)

    cmp_release = CompareOpenStackReleases(release)
    packages = deepcopy(BASE_PACKAGES)
    if cmp_release >= 'rocky':
        packages.extend(PY3_PACKAGES)
        if config('enable-fwaas') and cmp_release <= 'ussuri':
            packages.append('python3-neutron-fwaas')
        if cmp_release >= 'train':
            packages.remove('python3-neutron-lbaas')

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages', 'neutron')
            packages.extend(pkgs)

    packages.extend(token_cache_pkgs(release=release))

    if cmp_release < 'rocky':
        if cmp_release >= 'kilo':
            packages.extend(KILO_PACKAGES)
            if config('enable-fwaas'):
                packages.append('python-neutron-fwaas')
        if cmp_release >= 'ocata':
            packages.append('python-neutron-dynamic-routing')
        if cmp_release >= 'pike':
            packages.remove('python-neutron-vpnaas')

        if release == 'kilo' or cmp_release >= 'mitaka':
            packages.append('python-networking-hyperv')

    if config('neutron-plugin') == 'vsp' and cmp_release < 'newton':
        nuage_pkgs = config('nuage-packages').split()
        packages.extend(nuage_pkgs)

    if cmp_release >= 'rocky':
        packages = [p for p in packages if not p.startswith('python-')]

    return list(set(packages))
Ejemplo n.º 47
0
def determine_packages():
    pkgs = []
    py3_pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
        _os_release = os_release('neutron-common', base='icehouse')
        # per 17.08 release notes L3HA + DVR is a Newton+ feature
        if (use_l3ha() and CompareOpenStackReleases(_os_release) >= 'newton'):
            pkgs.extend(L3HA_PACKAGES)
        # python3-neutron-fwaas is already dependency package on
        # neutron-l3-agent. However this need to be added to py3_pkgs
        # to support switch from py2 to py3 in Rocky release.
        if CompareOpenStackReleases(_os_release) == 'rocky':
            py3_pkgs.append('python3-neutron-fwaas')
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    cmp_release = CompareOpenStackReleases(
        os_release('neutron-common', base='icehouse', reset_cache=True))
    if cmp_release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    if enable_sriov():
        if cmp_release >= 'mitaka':
            pkgs.append('neutron-sriov-agent')
        else:
            pkgs.append('neutron-plugin-sriov-agent')

    if use_hw_offload():
        pkgs.append('mlnx-switchdev-mode')

    if cmp_release >= 'rocky':
        pkgs = [p for p in pkgs if not p.startswith('python-')]
        pkgs.extend(PY3_PACKAGES)
        pkgs.extend(py3_pkgs)

    return pkgs
Ejemplo n.º 48
0
def determine_packages():
    pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)

    if git_install_requested():
        pkgs.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in pkgs:
                pkgs.remove(p)

    return pkgs
Ejemplo n.º 49
0
def determine_packages():
    # currently all packages match service names
    packages = [] + BASE_PACKAGES
    for v in resource_map().values():
        packages.extend(v['services'])
    if network_manager() in ['neutron', 'quantum']:
        pkgs = neutron_plugin_attribute(neutron_plugin(), 'server_packages',
                                        network_manager())
        packages.extend(pkgs)
    if console_attributes('packages'):
        packages.extend(console_attributes('packages'))

    if git_install_requested():
        packages = list(set(packages))
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)

    return list(set(packages))
Ejemplo n.º 50
0
def determine_packages():
    # currently all packages match service names
    packages = [] + BASE_PACKAGES
    for v in resource_map().values():
        packages.extend(v['services'])
    if network_manager() in ['neutron', 'quantum']:
        pkgs = neutron_plugin_attribute(neutron_plugin(), 'server_packages',
                                        network_manager())
        packages.extend(pkgs)
    if console_attributes('packages'):
        packages.extend(console_attributes('packages'))

    if git_install_requested():
        packages = list(set(packages))
        packages.extend(BASE_GIT_PACKAGES)
        # don't include packages that will be installed from git
        for p in GIT_PACKAGE_BLACKLIST:
            if p in packages:
                packages.remove(p)

    return list(set(packages))
def determine_packages():
    pkgs = []
    py3_pkgs = []
    plugin_pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron')
    for plugin_pkg in plugin_pkgs:
        pkgs.extend(plugin_pkg)
    if use_dvr():
        pkgs.extend(DVR_PACKAGES)
        py3_pkgs.append('python3-neutron-fwaas')
        _os_release = os_release('neutron-common', base='icehouse')
        # per 17.08 release notes L3HA + DVR is a Newton+ feature
        if (use_l3ha() and
           CompareOpenStackReleases(_os_release) >= 'newton'):
            pkgs.extend(L3HA_PACKAGES)
    if enable_local_dhcp():
        pkgs.extend(DHCP_PACKAGES)
        pkgs.extend(METADATA_PACKAGES)

    cmp_release = CompareOpenStackReleases(
        os_release('neutron-common', base='icehouse',
                   reset_cache=True))
    if cmp_release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs:
        pkgs.remove('neutron-plugin-openvswitch-agent')
        pkgs.append('neutron-openvswitch-agent')

    if use_dpdk():
        pkgs.append('openvswitch-switch-dpdk')

    if enable_sriov():
        if cmp_release >= 'mitaka':
            pkgs.append('neutron-sriov-agent')
        else:
            pkgs.append('neutron-plugin-sriov-agent')

    if cmp_release >= 'rocky':
        pkgs = [p for p in pkgs if not p.startswith('python-')]
        pkgs.extend(PY3_PACKAGES)
        pkgs.extend(py3_pkgs)

    return pkgs
def determine_packages():
    packages = [] + BASE_PACKAGES

    net_manager = network_manager()
    if (net_manager in ['flatmanager', 'flatdhcpmanager'] and
            config('multi-host').lower() == 'yes'):
        packages.extend(['nova-api', 'nova-network'])
    elif net_manager == 'quantum':
        plugin = neutron_plugin()
        packages.extend(
            neutron_plugin_attribute(plugin, 'packages', net_manager))

    if relation_ids('ceph'):
        packages.append('ceph-common')

    virt_type = config('virt-type')
    try:
        packages.extend(VIRT_TYPES[virt_type])
    except KeyError:
        log('Unsupported virt-type configured: %s' % virt_type)
        raise

    return packages
def determine_packages(source=None):
    # currently all packages match service names
    release = get_os_codename_install_source(source)
    cmp_release = CompareOpenStackReleases(release)
    packages = deepcopy(BASE_PACKAGES)
    if cmp_release >= 'rocky':
        packages.extend(PY3_PACKAGES)

    for v in resource_map().values():
        packages.extend(v['services'])
        if manage_plugin():
            pkgs = neutron_plugin_attribute(config('neutron-plugin'),
                                            'server_packages',
                                            'neutron')
            packages.extend(pkgs)

    packages.extend(token_cache_pkgs(release=release))

    if cmp_release < 'rocky':
        if cmp_release >= 'kilo':
            packages.extend(KILO_PACKAGES)
        if cmp_release >= 'ocata':
            packages.append('python-neutron-dynamic-routing')
        if cmp_release >= 'pike':
            packages.remove('python-neutron-vpnaas')

        if release == 'kilo' or cmp_release >= 'mitaka':
            packages.append('python-networking-hyperv')

    if config('neutron-plugin') == 'vsp':
        nuage_pkgs = config('nuage-packages').split()
        packages.extend(nuage_pkgs)

    if cmp_release >= 'rocky':
        packages = [p for p in packages if not p.startswith('python-')]

    return list(set(packages))
def migrate_neutron_database(upgrade=False):
    '''Initializes a new database or upgrades an existing database.'''

    if not upgrade and is_db_initialised():
        log("Database is already initialised.", level=DEBUG)
        return

    log('Migrating the neutron database.')
    if(os_release('neutron-server') == 'juno' and
       config('neutron-plugin') == 'vsp'):
        nuage_vsp_juno_neutron_migration()
    else:
        plugin = config('neutron-plugin')
        cmd = ['neutron-db-manage',
               '--config-file', NEUTRON_CONF,
               '--config-file', neutron_plugin_attribute(plugin,
                                                         'config',
                                                         'neutron'),
               'upgrade',
               'head']
        subprocess.check_output(cmd)

    cluster_rids = relation_ids('cluster')
    if cluster_rids:
        # Notify peers so that services get restarted
        log("Notifying peer(s) that db is initialised and restarting services",
            level=DEBUG)
        for r_id in cluster_rids:
            if not is_unit_paused_set():
                service_restart('neutron-server')

            # Notify peers that tey should also restart their services
            shared_db_rel_id = (relation_ids('shared-db') or [None])[0]
            id = "{}-{}-{}".format(local_unit(), shared_db_rel_id,
                                   uuid.uuid4())
            relation_set(relation_id=r_id, **{NEUTRON_DB_INIT_RKEY: id})
def determine_packages():
    '''
    Returns list of packages required by PLUMgrid director as specified
    in the neutron_plugins dictionary in charmhelpers.
    '''
    pkgs = []
    tag = 'latest'
    for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
        if 'plumgrid' in pkg:
            tag = config('plumgrid-build')
        elif pkg == 'iovisor-dkms':
            tag = config('iovisor-build')

        if tag == 'latest':
            pkgs.append(pkg)
        else:
            if tag in [i.ver_str for i in apt_cache()[pkg].version_list]:
                pkgs.append('%s=%s' % (pkg, tag))
            else:
                error_msg = \
                    "Build version '%s' for package '%s' not available" \
                    % (tag, pkg)
                raise ValueError(error_msg)
    return pkgs
Ejemplo n.º 56
0
def determine_packages():
    '''
    Returns list of packages required by PLUMgrid Gateway as specified
    in the neutron_plugins dictionary in charmhelpers.
    '''
    pkgs = []
    tag = 'latest'
    for pkg in neutron_plugin_attribute('plumgrid', 'packages', 'neutron'):
        if 'plumgrid' in pkg:
            tag = config('plumgrid-build')
        elif pkg == 'iovisor-dkms':
            tag = config('iovisor-build')

        if tag == 'latest':
            pkgs.append(pkg)
        else:
            if tag in [i.ver_str for i in apt_cache()[pkg].version_list]:
                pkgs.append('%s=%s' % (pkg, tag))
            else:
                error_msg = \
                    "Build version '%s' for package '%s' not available" \
                    % (tag, pkg)
                raise ValueError(error_msg)
    return pkgs
def determine_packages():
    return neutron_plugin_attribute('Calico', 'packages', 'neutron')
Ejemplo n.º 58
0
def postgresql_neutron_db_changed():
    if network_manager() in ['neutron', 'quantum']:
        plugin = neutron_plugin()
        # DB config might have been moved to main neutron.conf in H?
        CONFIGS.write(neutron_plugin_attribute(plugin, 'config'))
Ejemplo n.º 59
0
def resource_map():
    '''
    Dynamically generate a map of resources that will be managed for a single
    hook execution.
    '''
    resource_map = deepcopy(BASE_RESOURCE_MAP)

    if relation_ids('nova-volume-service'):
        # if we have a relation to a nova-volume service, we're
        # also managing the nova-volume API endpoint (legacy)
        resource_map['/etc/nova/nova.conf']['services'].append(
            'nova-api-os-volume')

    net_manager = network_manager()

    if os.path.exists('/etc/apache2/conf-available'):
        resource_map.pop(APACHE_CONF)
    else:
        resource_map.pop(APACHE_24_CONF)

    resource_map[NOVA_CONF]['contexts'].append(
        nova_cc_context.NeutronCCContext())
    # pop out irrelevant resources from the OrderedDict (easier than adding
    # them late)
    if net_manager != 'quantum':
        [
            resource_map.pop(k) for k in list(resource_map.iterkeys())
            if 'quantum' in k
        ]
    if net_manager != 'neutron':
        [
            resource_map.pop(k) for k in list(resource_map.iterkeys())
            if 'neutron' in k
        ]
    # add neutron plugin requirements. nova-c-c only needs the
    # neutron-server associated with configs, not the plugin agent.
    if net_manager in ['quantum', 'neutron']:
        plugin = neutron_plugin()
        if plugin:
            conf = neutron_plugin_attribute(plugin, 'config', net_manager)
            ctxts = (neutron_plugin_attribute(plugin, 'contexts', net_manager)
                     or [])
            services = neutron_plugin_attribute(plugin, 'server_services',
                                                net_manager)
            resource_map[conf] = {}
            resource_map[conf]['services'] = services
            resource_map[conf]['contexts'] = ctxts
            resource_map[conf]['contexts'].append(
                nova_cc_context.NeutronCCContext())

            # update for postgres
            resource_map[conf]['contexts'].append(
                nova_cc_context.NeutronPostgresqlDBContext())

    if is_relation_made('neutron-api'):
        for k in list(resource_map.iterkeys()):
            # neutron-api runs neutron services
            if 'quantum' in k or 'neutron' in k:
                resource_map[k]['services'] = []
        resource_map[NOVA_CONF]['contexts'].append(
            nova_cc_context.NeutronAPIContext())

    # nova-conductor for releases >= G.
    if os_release('nova-common') not in ['essex', 'folsom']:
        resource_map['/etc/nova/nova.conf']['services'] += ['nova-conductor']

    if console_attributes('services'):
        resource_map['/etc/nova/nova.conf']['services'] += \
            console_attributes('services')

    # also manage any configs that are being updated by subordinates.
    vmware_ctxt = context.SubordinateConfigContext(interface='nova-vmware',
                                                   service='nova',
                                                   config_file=NOVA_CONF)
    vmware_ctxt = vmware_ctxt()
    if vmware_ctxt and 'services' in vmware_ctxt:
        for s in vmware_ctxt['services']:
            if s not in resource_map[NOVA_CONF]['services']:
                resource_map[NOVA_CONF]['services'].append(s)

    return resource_map
Ejemplo n.º 60
0
 def packages(self):
     return neutron_plugin_attribute(
         self.plugin, 'packages', self.network_manager)