Example #1
0
    def test_apt_dist_upgrade_fatal(self, log, mock_call):
        options = ['--foo', '--bar']
        fetch.apt_upgrade(options, fatal=True, dist=True)

        mock_call.assert_called_with(
            ['apt-get', '--assume-yes', '--foo', '--bar', 'dist-upgrade'],
            env=getenv({'DEBIAN_FRONTEND': 'noninteractive'}))
Example #2
0
def do_openstack_upgrade(configs):
    """Perform an uprade of cinder. Takes care of upgrading
    packages, rewriting configs + database migration and
    potentially any other post-upgrade actions.

    :param configs: The charms main OSConfigRenderer object.

    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    juju_log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    # set CONFIGS to load templates from new release and regenerate config
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()

    # Stop/start services and migrate DB if leader
    [service_stop(s) for s in services()]
    if is_elected_leader(CLUSTER_RES):
        migrate_database()
    [service_start(s) for s in services()]
Example #3
0
def do_openstack_upgrade(configs):
    """Perform an upgrade of glance.  Takes care of upgrading
    packages, rewriting configs + database migration and potentially
    any other post-upgrade actions.

    :param configs: The charms main OSConfigRenderer object.

    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    apt_install(determine_packages(), fatal=True)

    # set CONFIGS to load templates from new release and regenerate config
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()

    [service_stop(s) for s in services()]
    if is_elected_leader(CLUSTER_RES):
        migrate_database()
    # Don't start services if the unit is supposed to be paused.
    if not is_unit_paused_set():
        [service_start(s) for s in services()]
def install():
    status_set('maintenance', 'Installing...')
    configure_sources(True, "install-sources", "install-keys")
    apt_update(fatal=True)
    apt_upgrade(fatal=True, dist=False)
    apt_install(PACKAGES, fatal=True)
    status_set("blocked", "Missing relation to contrail-controller")
def _aci_install(relation_id=None):
    log("Installing ACI packages")

    pkgs = [
        'python-apicapi', 'neutron-ml2-driver-apic', 'group-based-policy',
        'python-group-based-policy-client', 'neutron-opflex-agent'
    ]
    gbp_pkgs = ['group-based-policy', 'python-group-based-policy-client']
    opt = [
        '--option=Dpkg::Options::=--force-confdef',
        '--option=Dpkg::Options::=--force-confold'
    ]

    conf = config()

    if 'aci-repo-key' in conf.keys():
        fetch.add_source(conf['aci-repo'], key=conf['aci-repo-key'])
    else:
        fetch.add_source(conf['aci-repo'])
        opt.append('--allow-unauthenticated')

    fetch.apt_update(fatal=True)
    fetch.apt_upgrade(fatal=True)

    for pkg in pkgs:
        fetch.apt_install(pkg, options=opt, fatal=True)

    if conf['use-gbp']:
        for pkg in gbp_pkgs:
            fetch.apt_install(pkg, options=opt, fatal=True)
Example #6
0
def install():
    configure_installation_source(config["openstack-origin"])
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    apt_install(PACKAGES, fatal=True)
    fix_permissions()
    fix_nodemgr()
def aci_opflex_install_pkgs():
    opt = ['--option=Dpkg::Options::=--force-confdef' ,'--option=Dpkg::Options::=--force-confold']

    conf = config()

    if 'aci-repo-key' in conf.keys():
        fetch.add_source(conf['aci-repo'], key=conf['aci-repo-key'])
    else:
        fetch.add_source(conf['aci-repo'])
        opt.append('--allow-unauthenticated')

    fetch.apt_update(fatal=True)
    fetch.apt_upgrade(fatal=True)

    fetch.apt_install(['neutron-common', 'neutron-server'], options=opt, fatal=True)
    fetch.apt_install(ACI_OPFLEX_PACKAGES, options=opt, fatal=True)

    cmd = ['/bin/systemctl', 'stop', 'neutron-metadata-agent']
    subprocess.check_call(cmd)

    cmd = ['/bin/systemctl', 'disable', 'neutron-metadata-agent']
    subprocess.check_call(cmd)

    cmd = ['touch', '/etc/neutron/plugin.ini']
    subprocess.check_call(cmd)
Example #8
0
    def do_openstack_pkg_upgrade(self):
        """Upgrade OpenStack packages and snaps

        :returns: None
        """
        new_src = self.config[self.source_config_key]
        new_os_rel = os_utils.get_os_codename_install_source(new_src)
        hookenv.log('Performing OpenStack upgrade to %s.' % (new_os_rel))

        # TODO(jamespage): Deal with deb->snap->deb migrations
        if os_utils.snap_install_requested() and self.all_snaps:
            os_utils.install_os_snaps(
                snaps=os_utils.get_snaps_install_info_from_origin(
                    self.all_snaps,
                    self.config[self.source_config_key],
                    mode=self.snap_mode),
                refresh=True)

        os_utils.configure_installation_source(new_src)
        fetch.apt_update()

        dpkg_opts = [
            '--option',
            'Dpkg::Options::=--force-confnew',
            '--option',
            'Dpkg::Options::=--force-confdef',
        ]
        fetch.apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
        fetch.apt_install(packages=self.all_packages,
                          options=dpkg_opts,
                          fatal=True)
        self.remove_obsolete_packages()
        self.release = new_os_rel
Example #9
0
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    cur_os_rel = os_release('neutron-common')
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    pkgs = determine_packages(new_os_rel)
    # Sort packages just to make unit tests easier
    pkgs.sort()
    apt_install(packages=pkgs, options=dpkg_opts, fatal=True)

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
    # Before kilo it's nova-cloud-controllers job
    if is_elected_leader(CLUSTER_RES) and new_os_rel >= 'kilo':
        stamp_neutron_database(cur_os_rel)
        migrate_neutron_database()
def heat_plugin_joined(rel_id=None):
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    apt_install(["contrail-heat"], fatal=True)

    try:
        output = check_output(
            ["dpkg-query", "-f", "${Version}\\n", "-W", "contrail-heat"])
        version = output.decode('UTF-8').rstrip()
        application_version_set(version)
    except CalledProcessError:
        return None
    plugin_dirs = config.get("heat-plugin-dirs")
    ctx = get_context()
    sections = {
        "clients_contrail": [("user", ctx.get("keystone_admin_user")),
                             ("password", ctx.get("keystone_admin_password")),
                             ("tenant", ctx.get("keystone_admin_tenant")),
                             ("api_server", ctx.get("api_server")),
                             ("auth_host_ip", ctx.get("keystone_ip"))]
    }

    conf = {"heat": {"/etc/heat/heat.conf": {"sections": sections}}}
    settings = {
        "plugin-dirs": plugin_dirs,
        "subordinate_configuration": json.dumps(conf)
    }
    relation_set(relation_id=rel_id, relation_settings=settings)
Example #11
0
def do_openstack_upgrade(configs):
    """Perform an uprade of heat.

    Takes care of upgrading packages,
    rewriting configs and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.

    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(packages=determine_packages(), options=dpkg_opts, fatal=True)

    remove_old_packages()

    # set CONFIGS to load templates from new release and regenerate config
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()

    migrate_database()
def do_openstack_upgrade(configs):
    # NOTE(jamespage) horrible hack to make utils forget a cached value
    import charmhelpers.contrib.openstack.utils as utils
    utils.os_rel = None
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    apt_update(fatal=True)

    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]

    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    apt_install(determine_packages(), fatal=True)

    remove_old_packages()

    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
    if not is_unit_paused_set():
        for s in services():
            service_restart(s)
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    cur_os_rel = os_release('neutron-common')
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    pkgs = determine_packages(new_os_rel)
    # Sort packages just to make unit tests easier
    pkgs.sort()
    apt_install(packages=pkgs,
                options=dpkg_opts,
                fatal=True)

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
    # Before kilo it's nova-cloud-controllers job
    if is_elected_leader(CLUSTER_RES):
        #stamp_neutron_database(cur_os_rel)
        migrate_neutron_database()
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.
    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)

    # NOTE(jamespage):
    # Write-out new openstack release configuration files prior to upgrading
    # to avoid having to restart services immediately after upgrade.
    configs = register_configs(new_os_rel)
    configs.write_all()

    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts,
                fatal=True, dist=True)
    # The cached version of os_release will now be invalid as the pkg version
    # should have changed during the upgrade.
    reset_os_release()
    apt_install(get_early_packages(), fatal=True)
    apt_install(get_packages(), fatal=True)
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    apt_install(packages=CEILOMETER_AGENT_PACKAGES,
                options=dpkg_opts,
                fatal=True)
    # Call apt_install a 2nd time to allow packages which are enabled
    # for specific OpenStack version to be installed . This is because
    # Openstack version for a subordinate should be derived from the
    # version of an installed package rather than relying on
    # openstack-origin which would not be present in a subordinate.
    apt_install(get_packages(), fatal=True)

    remove_old_packages()

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
def config_changed():
    if config.changed("install-sources") or config.changed("install-keys"):
        configure_sources(True, "install-sources", "install-keys")
        apt_update(fatal=True)
        apt_upgrade(fatal=True, dist=False)

    if is_leader():
        _configure_metadata_shared_secret()
def install():
    configure_installation_source(config["openstack-origin"])
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    apt_install(PACKAGES, fatal=True)
    fix_services()
    write_nodemgr_config()
    service_restart("contrail-config-nodemgr")
def install():
    configure_installation_source(config["openstack-origin"])
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    apt_install(PACKAGES, fatal=True)
    fix_services()
    write_nodemgr_config()
    service_restart("contrail-config-nodemgr")
def additional_install_locations(plugin, source):
    '''
    Add any required additional package locations for the charm, based
    on the Neutron plugin being used. This will also force an immediate
    package upgrade.
    '''
    release = get_os_codename_install_source(source)
    if plugin == 'Calico':
        if config('calico-origin'):
            calico_source = config('calico-origin')
        elif release in ('icehouse', 'juno', 'kilo'):
            # Prior to the Liberty release, Calico's Nova and Neutron changes
            # were not fully upstreamed, so we need to point to a
            # release-specific PPA that includes Calico-specific Nova and
            # Neutron packages.
            calico_source = 'ppa:project-calico/%s' % release
        else:
            # From Liberty onwards, we can point to a PPA that does not include
            # any patched OpenStack packages, and hence is independent of the
            # OpenStack release.
            calico_source = 'ppa:project-calico/stable'

        add_source(calico_source)

    elif plugin == 'midonet':
        midonet_origin = config('midonet-origin')
        release_num = midonet_origin.split('-')[1]

        if midonet_origin.startswith('mem'):
            with open(os.path.join(charm_dir(),
                                   'files/midokura.key')) as midokura_gpg_key:
                priv_gpg_key = midokura_gpg_key.read()
            mem_username = config('mem-username')
            mem_password = config('mem-password')
            if release in ('juno', 'kilo', 'liberty'):
                add_source(
                    'deb http://%s:%[email protected]/openstack/%s/stable '
                    'trusty main' % (mem_username, mem_password, release),
                    key=priv_gpg_key)
            add_source('http://%s:%[email protected]/midonet/v%s/stable '
                       'main' % (mem_username, mem_password, release_num),
                       key=priv_gpg_key)
        else:
            with open(os.path.join(charm_dir(),
                                   'files/midonet.key')) as midonet_gpg_key:
                pub_gpg_key = midonet_gpg_key.read()
            if release in ('juno', 'kilo', 'liberty'):
                add_source(
                    'deb http://repo.midonet.org/openstack-%s stable main' %
                    release,
                    key=pub_gpg_key)

            add_source('deb http://repo.midonet.org/midonet/v%s stable main' %
                       release_num,
                       key=pub_gpg_key)

        apt_update(fatal=True)
        apt_upgrade(fatal=True)
def _do_openstack_upgrade(new_src):
    enable_policy_rcd()
    cur_os_rel = os_release('nova-common')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]

    # NOTE(jamespage) pre-stamp neutron database before upgrade from grizzly
    if cur_os_rel == 'grizzly':
        neutron_db_manage(['stamp', 'grizzly'])

    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    disable_policy_rcd()

    if cur_os_rel == 'grizzly':
        # NOTE(jamespage) when upgrading from grizzly->havana, config
        # files need to be generated prior to performing the db upgrade
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()
        neutron_db_manage(['upgrade', 'head'])
    else:
        if new_os_rel < 'kilo':
            neutron_db_manage(['stamp', cur_os_rel])
            migrate_neutron_database()
        # NOTE(jamespage) upgrade with existing config files as the
        # havana->icehouse migration enables new service_plugins which
        # create issues with db upgrades
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()

    if new_os_rel >= 'mitaka' and not database_setup(prefix='novaapi'):
        # NOTE: Defer service restarts and database migrations for now
        #       as nova_api database is not yet created
        if (relation_ids('cluster') and
                is_elected_leader(CLUSTER_RES)):
            # NOTE: reset dbsync state so that migration will complete
            #       when the nova_api database is setup.
            peer_store('dbsync_state', None)
        return configs

    if is_elected_leader(CLUSTER_RES):
        status_set('maintenance', 'Running nova db migration')
        migrate_nova_database()
    if not is_unit_paused_set():
        [service_start(s) for s in services()]

    return configs
def additional_install_locations(plugin, source):
    '''
    Add any required additional package locations for the charm, based
    on the Neutron plugin being used. This will also force an immediate
    package upgrade.
    '''
    release = get_os_codename_install_source(source)
    if plugin == 'Calico':
        if config('calico-origin'):
            calico_source = config('calico-origin')
        elif release in ('icehouse', 'juno', 'kilo'):
            # Prior to the Liberty release, Calico's Nova and Neutron changes
            # were not fully upstreamed, so we need to point to a
            # release-specific PPA that includes Calico-specific Nova and
            # Neutron packages.
            calico_source = 'ppa:project-calico/%s' % release
        else:
            # From Liberty onwards, we can point to a PPA that does not include
            # any patched OpenStack packages, and hence is independent of the
            # OpenStack release.
            calico_source = 'ppa:project-calico/stable'

        add_source(calico_source)

    elif plugin == 'midonet':
        midonet_origin = config('midonet-origin')
        release_num = midonet_origin.split('-')[1]

        if midonet_origin.startswith('mem'):
            with open(os.path.join(charm_dir(),
                                   'files/midokura.key')) as midokura_gpg_key:
                priv_gpg_key = midokura_gpg_key.read()
            mem_username = config('mem-username')
            mem_password = config('mem-password')
            if release in ('juno', 'kilo', 'liberty'):
                add_source(
                    'deb http://%s:%[email protected]/openstack/%s/stable '
                    'trusty main' % (mem_username, mem_password, release),
                    key=priv_gpg_key)
            add_source('http://%s:%[email protected]/midonet/v%s/stable '
                       'main' % (mem_username, mem_password, release_num),
                       key=priv_gpg_key)
        else:
            with open(os.path.join(charm_dir(),
                                   'files/midonet.key')) as midonet_gpg_key:
                pub_gpg_key = midonet_gpg_key.read()
            if release in ('juno', 'kilo', 'liberty'):
                add_source(
                    'deb http://repo.midonet.org/openstack-%s stable main' %
                    release, key=pub_gpg_key)

            add_source('deb http://repo.midonet.org/midonet/v%s stable main' %
                       release_num, key=pub_gpg_key)

        apt_update(fatal=True)
        apt_upgrade(fatal=True)
def config_changed():
    if config.changed("install-sources") or config.changed("install-keys"):
        configure_sources(True, "install-sources", "install-keys")
        apt_update(fatal=True)
        apt_upgrade(fatal=True, dist=False)
        _notify_neutron()

    if is_leader():
        res = _configure_metadata_shared_secret()
        if res:
            _notify_controller()
Example #24
0
def install():
    status_set("maintenance", "Installing...")

    # TODO: try to remove this call
    fix_hostname()

    apt_upgrade(fatal=True, dist=True)
    add_docker_repo()
    apt_update(fatal=False)
    apt_install(PACKAGES + DOCKER_PACKAGES, fatal=True)

    update_charm_status()
Example #25
0
def install():
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    fix_vrouter_scripts()  # bug in 2.0+20141015.1 packages
    apt_install(PACKAGES, fatal=True)
    fix_permissions()
    fix_nodemgr()
    if config.get("remove-juju-bridge"):
        remove_juju_bridge()
    modprobe("vrouter", True, True)
    configure_vrouter()
    service_restart("nova-compute")
Example #26
0
def _do_openstack_upgrade(new_src):
    enable_policy_rcd()
    cur_os_rel = os_release('nova-common')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]

    # NOTE(jamespage) pre-stamp neutron database before upgrade from grizzly
    if cur_os_rel == 'grizzly':
        neutron_db_manage(['stamp', 'grizzly'])

    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    if cur_os_rel == 'grizzly':
        # NOTE(jamespage) when upgrading from grizzly->havana, config
        # files need to be generated prior to performing the db upgrade
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()
        neutron_db_manage(['upgrade', 'head'])
    else:
        if new_os_rel < 'kilo':
            neutron_db_manage(['stamp', cur_os_rel])
            migrate_neutron_database()
        # NOTE(jamespage) upgrade with existing config files as the
        # havana->icehouse migration enables new service_plugins which
        # create issues with db upgrades
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()

    if new_os_rel == 'icehouse':
        # NOTE(jamespage) default plugin switch to ml2@icehouse
        ml2_migration()

    if is_elected_leader(CLUSTER_RES):
        migrate_nova_database()
    [service_start(s) for s in services()]

    disable_policy_rcd()

    return configs
Example #27
0
def install():
    status_set("maintenance", "Installing...")

    configure_crashes()
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    packages = list()
    packages.extend(PACKAGES)
    if not config.get("dpdk"):
        packages.extend(PACKAGES_DKMS_INIT)
    else:
        # services must not be started before config files creation
        if not init_is_systemd():
            with open("/etc/init/supervisor-vrouter.override", "w") as conf:
                conf.write("manual\n")
        else:
            # and another way with systemd
            for srv in ("contrail-vrouter-agent", "contrail-vrouter-dpdk"):
                try:
                    os.remove("/etc/systemd/system/{}.sevice".format(srv))
                except OSError:
                    pass
                os.symlink("/dev/null",
                           "/etc/systemd/system/{}.sevice".format(srv))
        packages.extend(PACKAGES_DPDK_INIT)
        # apt-get upgrade can install new kernel so we need to re-install
        # packages with dpdk drivers
        kver = check_output(["uname", "-r"]).rstrip()
        packages.append("linux-image-extra-" + kver)
    apt_install(packages, fatal=True)
    try:
        output = check_output([
            "dpkg-query", "-f", "${Version}\\n", "-W", "contrail-vrouter-agent"
        ])
        version = output.decode('UTF-8').rstrip()
        application_version_set(version)
    except CalledProcessError:
        return None

    status_set("maintenance", "Configuring...")
    os.chmod("/etc/contrail", 0o755)
    os.chown("/etc/contrail", 0, 0)

    if config.get("dpdk"):
        install_dpdk()
    else:
        # supervisord must be started after installation
        if not init_is_systemd():
            # supervisord
            service_restart("supervisor-vrouter")
        install_dkms()
Example #28
0
def do_openstack_upgrade(configs):
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel), level=DEBUG)
    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
def do_openstack_upgrade(configs):
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel), level=DEBUG)
    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
Example #30
0
def _do_openstack_upgrade(new_src):
    enable_policy_rcd()
    cur_os_rel = os_release('nova-common')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]

    # NOTE(jamespage) pre-stamp neutron database before upgrade from grizzly
    if cur_os_rel == 'grizzly':
        neutron_db_manage(['stamp', 'grizzly'])

    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    if cur_os_rel == 'grizzly':
        # NOTE(jamespage) when upgrading from grizzly->havana, config
        # files need to be generated prior to performing the db upgrade
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()
        neutron_db_manage(['upgrade', 'head'])
    else:
        if new_os_rel < 'kilo':
            neutron_db_manage(['stamp', cur_os_rel])
            migrate_neutron_database()
        # NOTE(jamespage) upgrade with existing config files as the
        # havana->icehouse migration enables new service_plugins which
        # create issues with db upgrades
        reset_os_release()
        configs = register_configs(release=new_os_rel)
        configs.write_all()

    if new_os_rel == 'icehouse':
        # NOTE(jamespage) default plugin switch to ml2@icehouse
        ml2_migration()

    if is_elected_leader(CLUSTER_RES):
        migrate_nova_database()
    [service_start(s) for s in services()]

    disable_policy_rcd()

    return configs
def install():
    status_set('maintenance', 'Installing...')

    # TODO: try to remove this call
    fix_hostname()

    apt_upgrade(fatal=True, dist=True)
    add_docker_repo()
    apt_update(fatal=False)
    apt_install(PACKAGES + DOCKER_PACKAGES, fatal=True)

    apply_docker_insecure()
    docker_login()

    update_charm_status()
def _do_openstack_upgrade(new_src):
    enable_policy_rcd()
    # All upgrades to Liberty are forced to step through Kilo. Liberty does
    # not have the migrate_flavor_data option (Bug #1511466) available so it
    # must be done pre-upgrade
    if os_release('nova-common') == 'kilo' and is_elected_leader(CLUSTER_RES):
        migrate_nova_flavors()
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]

    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    disable_policy_rcd()

    # NOTE(jamespage) upgrade with existing config files as the
    # havana->icehouse migration enables new service_plugins which
    # create issues with db upgrades
    reset_os_release()
    configs = register_configs(release=new_os_rel)
    configs.write_all()

    if new_os_rel >= 'mitaka' and not database_setup(prefix='novaapi'):
        # NOTE: Defer service restarts and database migrations for now
        #       as nova_api database is not yet created
        if (relation_ids('cluster') and is_elected_leader(CLUSTER_RES)):
            # NOTE: reset dbsync state so that migration will complete
            #       when the nova_api database is setup.
            peer_store('dbsync_state', None)
        return configs

    if is_elected_leader(CLUSTER_RES):
        status_set('maintenance', 'Running nova db migration')
        migrate_nova_database()
    if not is_unit_paused_set():
        [service_start(s) for s in services()]

    return configs
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    cur_os_rel = os_release('neutron-common')
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to {}.'.format(new_os_rel))

    add_source(new_src)

    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    pkgs = determine_packages(new_src)
    # Sort packages just to make unit tests easier
    pkgs.sort()
    apt_install(packages=pkgs, options=dpkg_opts, fatal=True)

    remove_old_packages()

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
    # write all configurations for any new parts required for
    # the new release.
    configs.write_all()
    # Before kilo it's nova-cloud-controllers job
    if is_elected_leader(CLUSTER_RES):
        # Stamping seems broken and unnecessary in liberty (Bug #1536675)
        if CompareOpenStackReleases(os_release('neutron-common')) < 'liberty':
            stamp_neutron_database(cur_os_rel)
        migrate_neutron_database(upgrade=True)
        if config('enable-fwaas'):
            if (CompareOpenStackReleases(new_os_rel) >= 'stein'
                    and CompareOpenStackReleases(new_os_rel) <= 'ussuri'):
                fwaas_migrate_v1_to_v2()
def do_openstack_upgrade(configs):
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))
    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
    if not is_paused():
        for service in SWIFT_SVCS:
            service_restart(service)
Example #35
0
def do_openstack_upgrade(configs):
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))
    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
    if not is_paused():
        for service in SWIFT_SVCS:
            service_restart(service)
Example #36
0
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.
    """
    new_src = config("openstack-origin")
    new_os_rel = get_os_codename_install_source(new_src)
    log("Performing OpenStack upgrade to %s." % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = ["--option", "Dpkg::Options::=--force-confnew", "--option", "Dpkg::Options::=--force-confdef"]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(get_early_packages(), fatal=True)
    apt_install(get_packages(), fatal=True)
    configs.write_all()
Example #37
0
def additional_install_locations(plugin, source):
    '''
    Add any required additional package locations for the charm, based
    on the Neutron plugin being used. This will also force an immediate
    package upgrade.
    '''
    if plugin == 'Calico':
        if config('calico-origin'):
            calico_source = config('calico-origin')
        else:
            release = get_os_codename_install_source(source)
            calico_source = 'ppa:project-calico/%s' % release

        add_source(calico_source)

        apt_update()
        apt_upgrade()
Example #38
0
def additional_install_locations(plugin, source):
    '''
    Add any required additional package locations for the charm, based
    on the Neutron plugin being used. This will also force an immediate
    package upgrade.
    '''
    if plugin == 'Calico':
        if config('calico-origin'):
            calico_source = config('calico-origin')
        else:
            release = get_os_codename_install_source(source)
            calico_source = 'ppa:project-calico/%s' % release

        add_source(calico_source)

        apt_update()
        apt_upgrade()
Example #39
0
def do_openstack_upgrade(configs=None):
    """Perform an uprade of cinder. Takes care of upgrading
    packages, rewriting configs + database migration and
    potentially any other post-upgrade actions.

    :param configs: The charms main OSConfigRenderer object.

    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    juju_log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option',
        'Dpkg::Options::=--force-confnew',
        '--option',
        'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    apt_install(determine_packages(), fatal=True)

    remove_old_packages()

    # NOTE(hopem): must do this after packages have been upgraded so that
    # we ensure that correct configs are selected for the target release.
    # See LP 1726527.
    configs = register_configs()

    # set CONFIGS to load templates from new release and regenerate config
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()

    if service_enabled('api') and run_in_apache():
        disable_package_apache_site()

    # Stop/start services and migrate DB if leader
    [service_stop(s) for s in services()]
    if is_elected_leader(CLUSTER_RES):
        migrate_database(upgrade=True)
    if not is_unit_paused_set():
        [service_start(s) for s in services()]
def do_openstack_upgrade(configs):
    """
    Perform an upgrade.  Takes care of upgrading packages, rewriting
    configs, database migrations and potentially any other post-upgrade
    actions.

    :param configs: The charms main OSConfigRenderer object.
    """
    cur_os_rel = os_release('neutron-common')
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update(fatal=True)
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    pkgs = determine_packages(new_src)
    # Sort packages just to make unit tests easier
    pkgs.sort()
    apt_install(packages=pkgs,
                options=dpkg_opts,
                fatal=True)

    remove_old_packages()

    # set CONFIGS to load templates from new release
    configs.set_release(openstack_release=new_os_rel)
    # write all configurations for any new parts required for
    # the new release.
    configs.write_all()
    # Before kilo it's nova-cloud-controllers job
    if is_elected_leader(CLUSTER_RES):
        # Stamping seems broken and unnecessary in liberty (Bug #1536675)
        if CompareOpenStackReleases(os_release('neutron-common')) < 'liberty':
            stamp_neutron_database(cur_os_rel)
        migrate_neutron_database(upgrade=True)
        if CompareOpenStackReleases(new_os_rel) >= 'stein':
            fwaas_migrate_v1_to_v2()
Example #41
0
def upgrade_charm():
    call([find_executable('sudo'), 'echo', config('triliovault-pkg-source'), '>', 
              '/etc/apt/sources.list.d/trilio-gemfury-sources.list'])

    new_src = config('openstack-origin')
    configure_installation_source(new_src)

    apt_update()
    apt_upgrade(fatal=True, dist=True)

    check_call([find_executable('systemctl'), 'daemon-reload'])
    service_restart('tvault-datamover-api')

    if config('python-version') == 2:
        dmapi_pkg = 'dmapi'
    else:
        dmapi_pkg = 'python3-dmapi'

    application_version_set(get_new_version(dmapi_pkg))
Example #42
0
def do_openstack_upgrade(configs=None):
    """Perform an uprade of cinder. Takes care of upgrading
    packages, rewriting configs + database migration and
    potentially any other post-upgrade actions.

    :param configs: The charms main OSConfigRenderer object.

    """
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)

    juju_log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]
    apt_update()
    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    reset_os_release()
    apt_install(determine_packages(), fatal=True)

    remove_old_packages()

    # NOTE(hopem): must do this after packages have been upgraded so that
    # we ensure that correct configs are selected for the target release.
    # See LP 1726527.
    configs = register_configs()

    # set CONFIGS to load templates from new release and regenerate config
    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()

    if run_in_apache():
        disable_package_apache_site()

    # Stop/start services and migrate DB if leader
    [service_stop(s) for s in services()]
    if is_elected_leader(CLUSTER_RES):
        migrate_database(upgrade=True)
    if not is_unit_paused_set():
        [service_start(s) for s in services()]
Example #43
0
def install():
    status_set("maintenance", "Installing...")

    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    packages = list()
    packages.extend(PACKAGES)
    # TODO: support dpdk config option
    packages.extend(PACKAGES_DKMS_INIT)
    apt_install(packages, fatal=True)
    try:
        output = check_output([
            "dpkg-query", "-f", "${Version}\\n", "-W", "contrail-vrouter-agent"
        ])
        version = output.decode('UTF-8').rstrip()
        application_version_set(version)
    except CalledProcessError:
        return None

    status_set("maintenance", "Configuring...")
    os.chmod("/etc/contrail", 0o755)
    os.chown("/etc/contrail", 0, 0)

    # supervisord must be started after installation
    release = lsb_release()["DISTRIB_CODENAME"]
    if release == 'trusty':
        # supervisord
        service_restart("supervisor-vrouter")

    try:
        log("Loading kernel module vrouter")
        modprobe("vrouter")
    except CalledProcessError:
        log("vrouter kernel module failed to load,"
            " clearing pagecache and retrying")
        drop_caches()
        modprobe("vrouter")
    dkms_autoinstall("vrouter")
    configure_vrouter_interface()
    config["vrouter-expected-provision-state"] = False
    status_set("blocked", "Missing relation to contrail-controller")
def upgrade_charm():
    os.system('sudo echo "{}" > '
              '/etc/apt/sources.list.d/trilio-gemfury-sources.list'.format(
                  config('triliovault-pkg-source')))

    new_src = config('openstack-origin')
    configure_installation_source(new_src)

    apt_update()
    apt_upgrade(fatal=True, dist=True)

    chownr('/var/log/dmapi', DMAPI_USR, DMAPI_GRP)

    check_call(['systemctl', 'daemon-reload'])
    service_restart('tvault-datamover-api')

    if config('python-version') == 2:
        dmapi_pkg = 'dmapi'
    else:
        dmapi_pkg = 'python3-dmapi'

    application_version_set(get_new_version(dmapi_pkg))
def do_openstack_upgrade(configs):
    # NOTE(jamespage) horrible hack to make utils forget a cached value
    import charmhelpers.contrib.openstack.utils as utils
    utils.os_rel = None
    new_src = config('openstack-origin')
    new_os_rel = get_os_codename_install_source(new_src)
    log('Performing OpenStack upgrade to %s.' % (new_os_rel))

    configure_installation_source(new_src)
    apt_update(fatal=True)

    dpkg_opts = [
        '--option', 'Dpkg::Options::=--force-confnew',
        '--option', 'Dpkg::Options::=--force-confdef',
    ]

    apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
    apt_install(determine_packages(), fatal=True)

    configs.set_release(openstack_release=new_os_rel)
    configs.write_all()
    [service_restart(s) for s in services()]
def additional_install_locations():
    '''
    Add any required additional install locations of the charm. This
    will also force an immediate upgrade.
    '''
    calico_source = 'ppa:project-calico/icehouse'

    if config('calico-origin') != 'default':
        calico_source = config('calico-origin')
    else:
        release = get_os_codename_install_source(config('openstack-origin'))
        if release in ('icehouse', 'juno', 'kilo'):
            # Prior to the Liberty release, Calico's Nova and Neutron changes
            # were not fully upstreamed, so we need to point to a
            # release-specific PPA that includes Calico-specific Nova and
            # Neutron packages.
            calico_source = 'ppa:project-calico/%s' % release
        else:
            # From Liberty onwards, we can point to a PPA that does not include
            # any patched OpenStack packages, and hence is independent of the
            # OpenStack release.
            calico_source = 'ppa:project-calico/calico-1.4'

    # Force UTF-8 to get the BIRD PPA to work.
    os.environ['LANG'] = 'en_US.UTF-8'
    add_source(calico_source)
    add_source('ppa:cz.nic-labs/bird')

    apt_update()
    apt_upgrade()

    # The new version of dnsmasq brings in new dependencies, so we need
    # to explicitly install it.
    apt_install(['dnsmasq-base'])

    return
def install():
    configure_sources(True, "install-sources", "install-keys")
    apt_upgrade(fatal=True, dist=True)
    apt_install(PACKAGES, fatal=True)