def install(): config = hookenv.config() host.adduser(USER, password='') host.mkdir(BASE_DIR, owner=USER, group=USER) # Meteor install script needs this os.environ['HOME'] = os.path.expanduser('~' + USER) hookenv.log('Installing dependencies') fetch.add_source(NODEJS_REPO) fetch.apt_update() fetch.apt_install(PACKAGES) hookenv.log('Installing Meteor') subprocess.check_call(DOWNLOAD_CMD.split()) subprocess.check_call(INSTALL_CMD.split()) subprocess.check_call('npm install -g meteorite'.split()) init_code(config) init_bundle(config) init_dependencies(config) hookenv.open_port(config['port']) subprocess.check_call( ['chown', '-R', '{user}:{user}'.format(user=USER), BASE_DIR]) config['mongo_url'] = '' write_upstart(config)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False) etcd_package_url = config('etcd-package-url') if etcd_package_url and etcd_package_url.startswith('http'): check_call([ "wget", etcd_package_url ]) check_call([ "dpkg", "-i", etcd_package_url.split('/')[-1] ])
def install(self): """Customise the installation, configure the source and then call the parent install() method to install the packages """ fetch.add_source('ppa:6wind/virt-mq-ppa') fetch.apt_install(self.packages, options=['--option=Dpkg::Options::=--force-confnew'])
def install(): juju_log('**********install.real') rsync( charm_dir() + '/packages/vsm-dep-repo', '/opt' ) rsync( charm_dir() + '/packages/vsmrepo', '/opt' ) rsync( charm_dir() + '/files/apt.conf', '/etc/apt' ) rsync( charm_dir() + '/files/vsm.list', '/etc/apt/sources.list.d' ) rsync( charm_dir() + '/files/vsm-dep.list', '/etc/apt/sources.list.d' ) apt_update() apt_install(VSM_PACKAGES) juju_log('**********finished to install vsm vsm-dashboard python-vsmclient') add_source(config('ceph-source'), config('ceph-key')) apt_update(fatal=True) apt_install(packages=PRE_INSTALL_PACKAGES, fatal=True)
def install(): add_source(config('source'), config('key')) apt_update(fatal=True) apt_install(packages=ceph.determine_packages(), fatal=True) if config('autotune'): tune_network_adapters() install_udev_rules()
def install_packages(): hookenv.status_set('maintenance', 'Installing packages') fetch.add_source('ppa:juju/stable') fetch.apt_update() packages = ['juju', 'juju-core', 'juju-deployer', 'git', 'python-yaml', 'python-jujuclient', 'charm-tools'] fetch.apt_install(fetch.filter_installed_packages(packages))
def upgrade_monitor(): current_version = ceph.get_version() status_set("maintenance", "Upgrading monitor") log("Current ceph version is {}".format(current_version)) new_version = config('release-version') log("Upgrading to: {}".format(new_version)) try: add_source(config('source'), config('key')) apt_update(fatal=True) except subprocess.CalledProcessError as err: log("Adding the ceph source failed with message: {}".format( err.message)) status_set("blocked", "Upgrade to {} failed".format(new_version)) sys.exit(1) try: if ceph.systemd(): for mon_id in ceph.get_local_mon_ids(): service_stop('ceph-mon@{}'.format(mon_id)) else: service_stop('ceph-mon-all') apt_install(packages=ceph.PACKAGES, fatal=True) if ceph.systemd(): for mon_id in ceph.get_local_mon_ids(): service_start('ceph-mon@{}'.format(mon_id)) else: service_start('ceph-mon-all') status_set("active", "") except subprocess.CalledProcessError as err: log("Stopping ceph and upgrading packages failed " "with message: {}".format(err.message)) status_set("blocked", "Upgrade to {} failed".format(new_version)) sys.exit(1)
def install(): log('Begin install hook.') execd_preinstall() add_source(config('source'), config('key')) apt_update(fatal=True) apt_install(packages=ceph.PACKAGES, fatal=True) install_upstart_scripts() log('End install hook.')
def install(): status_set('maintenance', 'Installing LXD packages') if config('source'): add_source(config('source')) apt_update(fatal=True) apt_install(determine_packages(), fatal=True) if config('use-source'): install_lxd_source() configure_lxd_source()
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('prefer-ipv6'): rabbit.assert_charm_supports_ipv6() # Add archive source if provided add_source(config('source'), config('key')) apt_update(fatal=True) # Copy in defaults file for updated ulimits shutil.copyfile( 'templates/rabbitmq-server', '/etc/default/rabbitmq-server') # Install packages to ensure any changes to source # result in an upgrade if applicable. status_set('maintenance', 'Installing/upgrading RabbitMQ packages') apt_install(rabbit.PACKAGES, fatal=True) open_port(5672) chown(RABBIT_DIR, rabbit.RABBIT_USER, rabbit.RABBIT_USER) chmod(RABBIT_DIR, 0o775) configure_nodename() if config('management_plugin') is True: rabbit.enable_plugin(MAN_PLUGIN) open_port(55672) else: rabbit.disable_plugin(MAN_PLUGIN) close_port(55672) rabbit.set_all_mirroring_queues(config('mirroring-queues')) rabbit.ConfigRenderer( rabbit.CONFIG_FILES).write_all() if is_relation_made("ha"): ha_is_active_active = config("ha-vip-only") if ha_is_active_active: update_nrpe_checks() else: if is_elected_leader('res_rabbitmq_vip'): update_nrpe_checks() else: log("hacluster relation is present but this node is not active" " skipping update nrpe checks") else: update_nrpe_checks() # NOTE(jamespage) # trigger amqp_changed to pickup and changes to network # configuration via the access-network config option. for rid in relation_ids('amqp'): for unit in related_units(rid): amqp_changed(relation_id=rid, remote_unit=unit)
def setup_ipv6(): ubuntu_rel = lsb_release()["DISTRIB_CODENAME"].lower() if ubuntu_rel < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. if ubuntu_rel == "trusty" and os_release("glance") < "liberty": add_source("deb http://archive.ubuntu.com/ubuntu trusty-backports " "main") apt_update() apt_install("haproxy/trusty-backports", fatal=True)
def install(): execd_preinstall() _release = lsb_release()['DISTRIB_CODENAME'].lower() if (config('source') is None and CompareHostReleases(_release) < 'trusty'): setup_percona_repo() elif config('source') is not None: add_source(config('source'), config('key')) apt_update(fatal=True) install_percona_xtradb_cluster()
def install(self): """Install packages and resources.""" # Install PPA if one has been defined. if self.config.get('driver-source'): fetch.add_source( self.config.get('driver-source'), key=self.config.get('driver-key')) fetch.apt_update() super().install() # All package install to run first incase payload has deps. self.install_resources() self.assess_status()
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if ubuntu_rel < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. if ubuntu_rel == 'trusty' and os_release('neutron-server') < 'liberty': add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(self): """install Install hook is run when the charm is first deployed on a node. """ import_key(hookenv.config('extra-key')) add_source(hookenv.config('extra-source')) apt_update() pkgs = NUAGE_PACKAGES for pkg in pkgs: apt_install(pkg, options=['--force-yes', '--allow-unauthenticated'], fatal=True)
def add_sources(self): """Add APT sources to allow installation of GitLab Runner from GitLab's packages.""" # https://packages.gitlab.com/runner/gitlab-runner/gpgkey # https://packages.gitlab.com/runner/gitlab-runner/ubuntu/ bionic main distro = get_distrib_codename() apt_key = self.apt_key apt_line = "deb https://packages.gitlab.com/runner/gitlab-runner/ubuntu/ {} main".format( distro) hookenv.log( "Installing and updating apt source for gitlab-runner: {} key {})". format(apt_line, apt_key)) add_source(apt_line, apt_key) self.kv.set('apt_key', apt_key) return True
def add_sources(self): """Ensure the GitLab apt repository is configured and updated for use.""" distro = host.get_distrib_codename() apt_repo = self.charm_config.get("apt_repo") apt_key = self.charm_config.get("apt_key") apt_line = "deb {}/{}/ubuntu {} main".format( apt_repo, self.package_name, distro ) hookenv.log( "Installing and updating apt source for {}: {} key {})".format( self.package_name, apt_line, apt_key ) ) add_source(apt_line, apt_key)
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if ubuntu_rel < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # NOTE(xianghui): Need to install haproxy(1.5.3) from trusty-backports # to support ipv6 address, so check is required to make sure not # breaking other versions, IPv6 only support for >= Trusty if ubuntu_rel == 'trusty': add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports' ' main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(): execd_preinstall() if config('source') is None and \ lsb_release()['DISTRIB_CODENAME'] < 'trusty': setup_percona_repo() elif config('source') is not None: add_source(config('source'), config('key')) configure_mysql_root_password(config('root-password')) apt_update(fatal=True) apt_install(determine_packages(), fatal=True) configure_sstuser(config('sst-password')) if config('harden') and 'mysql' in config('harden'): run_mysql_checks()
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if CompareHostReleases(ubuntu_rel) < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. if (ubuntu_rel == 'trusty' and CompareOpenStackReleases(os_release('nova-api')) < 'liberty'): add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def check_for_upgrade(): if not os.path.exists(ceph._upgrade_keyring): log("Ceph upgrade keyring not detected, skipping upgrade checks.") return c = hookenv.config() old_version = ceph.resolve_ceph_version(c.previous('source') or 'distro') log('old_version: {}'.format(old_version)) new_version = ceph.resolve_ceph_version(hookenv.config('source') or 'distro') log('new_version: {}'.format(new_version)) old_version_os = get_os_codename_install_source(c.previous('source') or 'distro') new_version_os = get_os_codename_install_source(hookenv.config('source')) # May be in a previous upgrade that was failed if the directories # still need an ownership update. Check this condition. resuming_upgrade = ceph.dirs_need_ownership_update('osd') if (ceph.UPGRADE_PATHS.get(old_version) == new_version) or\ resuming_upgrade: if old_version == new_version: log('Attempting to resume possibly failed upgrade.', INFO) else: log("{} to {} is a valid upgrade path. Proceeding.".format( old_version, new_version)) emit_cephconf(upgrading=True) ceph.roll_osd_cluster(new_version=new_version, upgrade_key='osd-upgrade') emit_cephconf(upgrading=False) elif (old_version == new_version and old_version_os < new_version_os): # See LP: #1778823 add_source(hookenv.config('source'), hookenv.config('key')) log(("The installation source has changed yet there is no new major " "version of Ceph in this new source. As a result no package " "upgrade will take effect. Please upgrade manually if you need " "to."), level=INFO) else: # Log a helpful error message log("Invalid upgrade path from {} to {}. " "Valid paths are: {}".format(old_version, new_version, ceph.pretty_print_upgrade_paths()), level=ERROR)
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if ubuntu_rel < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. os_pkg = 'openstack-dashboard' if ubuntu_rel == 'trusty' and os_release(os_pkg) < 'liberty': add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(self): log('Starting infoblox installation') installed = len(filter_installed_packages(self.packages)) == 0 if not installed: add_source(config('source')) apt_update(fatal=True) apt_install(self.packages[0], fatal=True) if not leader_get('pool'): if is_leader(): leader_set({ 'pool': str(uuid.uuid4()), 'pool_target': str(uuid.uuid4()), 'nameserver': str(uuid.uuid4()) }) status_set('active', 'Unit is ready')
def install(): execd_preinstall() if config('source') is None and \ lsb_release()['DISTRIB_CODENAME'] < 'trusty': setup_percona_repo() elif config('source') is not None: add_source(config('source'), config('key')) configure_mysql_root_password(config('root-password')) # Render base configuration (no cluster) render_config() apt_update(fatal=True) apt_install(determine_packages(), fatal=True) configure_rootpw(config('root-password')) configure_sstuser(config('sst-password'))
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if CompareHostReleases(ubuntu_rel) < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. _os_release = os_release('openstack-dashboard') if (ubuntu_rel == 'trusty' and CompareOpenStackReleases(_os_release) < 'liberty'): add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(): execd_preinstall() add_source(config('source'), config('key')) apt_update(fatal=True) apt_install(packages=ceph.determine_packages(), fatal=True) rm_packages = ceph.determine_packages_to_remove() if rm_packages: apt_purge(packages=rm_packages, fatal=True) try: # we defer and explicitly run `ceph-create-keys` from # add_keyring_to_ceph() as part of bootstrap process # LP: #1719436. service_pause('ceph-create-keys') except ValueError: pass
def install(): execd_preinstall() add_source(config_data['source'], config_data['key']) apt_update(fatal=True) apt_install(packages=CC_PACKAGES, fatal=True) host.adduser('vcap') host.write_file(CC_DB_FILE, '', owner='vcap', group='vcap', perms=0775) dirs = [CC_RUN_DIR, NGINX_RUN_DIR, CC_LOG_DIR, NGINX_LOG_DIR, '/var/vcap/data/cloud_controller_ng/tmp/uploads', '/var/vcap/data/cloud_controller_ng/tmp/staged_droplet_uploads', '/var/vcap/nfs/store'] for item in dirs: host.mkdir(item, owner='vcap', group='vcap', perms=0775) chownr('/var/vcap', owner='vcap', group='vcap') chownr(CF_DIR, owner='vcap', group='vcap') install_upstart_scripts()
def install(): hookenv.status_set('maintenance', 'Installing Ubuntu OpenStack Installer') add_source('ppa:cloud-installer/experimental') add_source('ppa:juju/stable') apt_update() apt_install(['openstack', 'python3-pytest', 'git']) ctx = _build_context() render(source='osi-config.yaml', target=os.path.join(CHARM_TMP, 'osi-config.yaml'), context=ctx) hookenv.status_set('maintenance', 'Cloning openstack-tests') hookenv.status_set('maintenance', 'Installing OpenStack') check_call(['sudo', 'openstack-install', '-c', os.path.join(CHARM_TMP, 'osi-config.yaml')]) hookenv.status_set('active', 'ready')
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 setup_source(release): """Install Jenkins archive.""" log("Configuring source of jenkins as %s" % release, level=INFO) # Configure to use upstream archives # lts - debian-stable # trunk - debian if release == 'lts': source = "debian-stable" elif release == 'trunk': source = "debian" else: errmsg = "Release '%s' configuration not recognised" % (release) raise Exception(errmsg) # Setup archive to use appropriate jenkins upstream key = 'http://pkg.jenkins-ci.org/%s/jenkins-ci.org.key' % source target = "%s-%s" % (source, 'jenkins-ci.org.key') subprocess.check_call(['wget', '-q', '-O', target, key]) with open(target, 'r') as fd: key = fd.read() deb = "deb http://pkg.jenkins-ci.org/%s binary/" % (source) sources_file = "/etc/apt/sources.list.d/jenkins.list" found = False if os.path.exists(sources_file): with open(sources_file, 'r') as fd: for line in fd: if deb in line: found = True break if not found: with open(sources_file, 'a') as fd: fd.write("%s\n" % deb) else: with open(sources_file, 'w') as fd: fd.write("%s\n" % deb) if not found: # NOTE: don't use add_source for adding source since it adds deb and # deb-src entries but pkg.jenkins-ci.org has no deb-src. add_source("#dummy-source", key=key) apt_update(fatal=True)
def setup_ipv6(): ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if CompareHostReleases(ubuntu_rel) < "trusty": raise Exception("IPv6 is not supported in the charms for Ubuntu " "versions less than Trusty 14.04") from apt import apt_pkg apt_pkg.init() # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. vc = apt_pkg.version_compare(get_pkg_version('haproxy'), '1.5.3') if ubuntu_rel == 'trusty' and vc == -1: add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update(fatal=True) apt_install('haproxy/trusty-backports', fatal=True)
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()
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) if neutron_plugin == 'vsp': source = config('nuage-tarball-url') if source is not None: try: handler = ArchiveUrlFetchHandler() packages = ['nuage-neutron'] path = handler.install(source) for package in packages: package_path = os.path.join(path, package) if os.path.exists(package_path): log('install {0} from: {1}'.format( package, package_path)) check_output([ 'bash', '-c', 'cd {}; sudo python setup.py install'.format( package_path) ]) except Exception as e: log('install failed with error: {}'.format(e.message)) raise Exception(e) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def install_ansible_support(from_ppa=True, ppa_location='ppa:rquillo/ansible'): """Installs the ansible package. By default it is installed from the `PPA`_ linked from the ansible `website`_ or from a ppa specified by a charm config.. .. _PPA: https://launchpad.net/~rquillo/+archive/ansible .. _website: http://docs.ansible.com/intro_installation.html#latest-releases-via-apt-ubuntu If from_ppa is empty, you must ensure that the package is available from a configured repository. """ if from_ppa: fetch.add_source(ppa_location) fetch.apt_update(fatal=True) fetch.apt_install('ansible') write_hosts_file()
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) if neutron_plugin == 'vsp': source = config('nuage-tarball-url') if source is not None: try: handler = ArchiveUrlFetchHandler() packages = ['nuage-neutron'] path = handler.install(source) for package in packages: package_path = os.path.join(path, package) if os.path.exists(package_path): log('install {0} from: {1}'.format(package, package_path)) check_output( [ 'bash', '-c', 'cd {}; sudo python setup.py install'.format( package_path) ] ) except Exception as e: log('install failed with error: {}'.format(e.message)) raise Exception(e) status_set('maintenance', 'Git install') git_install(config('openstack-origin-git')) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def test_add_source_deb(self, check_call): """add-apt-repository behaves differently when using the deb prefix. $ add-apt-repository --yes "http://special.example.com/ubuntu precise-special main" $ grep special /etc/apt/sources.list deb http://special.example.com/ubuntu precise precise-special main deb-src http://special.example.com/ubuntu precise precise-special main $ add-apt-repository --yes "deb http://special.example.com/ubuntu precise-special main" $ grep special /etc/apt/sources.list deb http://special.example.com/ubuntu precise precise-special main deb-src http://special.example.com/ubuntu precise precise-special main deb http://special.example.com/ubuntu precise-special main deb-src http://special.example.com/ubuntu precise-special main """ source = "deb http://archive.ubuntu.com/ubuntu raring-backports main" fetch.add_source(source=source) check_call.assert_called_with(['add-apt-repository', '--yes', source])
def add_source(source, key=None): '''Add an apt source. Sets the apt.needs_update state. A source may be either a line that can be added directly to sources.list(5), or in the form ppa:<user>/<ppa-name> for adding Personal Package Archives, or a distribution component to enable. The package signing key should be an ASCII armoured GPG key. While GPG key ids are also supported, the retrieval mechanism is insecure. There is no need to specify the package signing key for PPAs or for the main Ubuntu archives. ''' # Maybe we should remember which sources have been added already # so we don't waste time re-adding them. Is this time significant? fetch.add_source(source, key) reactive.set_state('apt.needs_update')
def install_plugin(ip, ver, venv): """Install Horizon plugin and workloadmgrclient packages from TVAULT_IPADDRESS provided by the user """ add_source('deb http://{}:8085 deb-repo/'.format(ip)) try: apt_update() apt_install(['python-workloadmgrclient'], options=['--allow-unauthenticated'], fatal=True) log("TrilioVault WorkloadMgrClient package installation passed") except Exception as e: # workloadmgrclient package install failed log("TrilioVault WorkloadMgrClient package installation failed") log("With exception --{}".format(e)) return False try: apt_install(['tvault-horizon-plugin'], options=['--allow-unauthenticated'], fatal=True) log("TrilioVault Horizon Plugin package installation passed") except Exception as e: # Horixon Plugin package install failed log("TrilioVault Horizon Plugin package installation failed") log("With exception --{}".format(e)) return False # Copy TrilioVault files copy_files() # Start the application status_set('maintenance', 'Starting...') try: service_restart("apache2") except Exception as e: # apache2 restart failed log("Apache2 restart failed with exception --{}".format(e)) return False return True
def install(): """Configure APT source. The many permutations of package source syntaxes in use does not allow us to simply call `add-apt-repository` on the unit and we need to make use of `charmhelpers.fetch.add_source` for this to be universally useful. """ source, key = os_utils.get_source_and_pgp_key(hookenv.config().get( 'source', 'distro')) fetch.add_source(source, key) fetch.apt_update(fatal=True) # The ``magpie`` charm is used as principle for functional tests with some # subordinate charms. Install the ``openstack-release`` package when # available to allow the functional test code to determine installed UCA # versions. fetch.apt_install(fetch.filter_installed_packages(['openstack-release']), fatal=False, quiet=True) set_state('charm.installed')
def install(): hookenv.status_set('maintenance', 'installing tor packages') # Installation is based on Tor installation instructions for Debian/Ubuntu: # https://www.torproject.org/docs/debian.html.en#ubuntu # Remove universe/multiverse from sources, to avoid the out-of-date tor # package. check_call(['sed', '-i.torinstall', '/universe/d;/multiverse/d;', '/etc/apt/sources.list']) check_call(['apt-get', 'clean']) add_source('deb http://deb.torproject.org/torproject.org trusty main', key='A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89') apt_update() # This may fail if torproject.org is blocked. OpenDNS censors it, for example. check_call(['apt-get', '-y', 'install', 'deb.torproject.org-keyring', 'tor']) hookenv.status_set('maintenance', 'tor installation complete')
def setup_ipv6(): """Validate that we can support IPv6 mode. This should be called if prefer-ipv6 is True to ensure that we are running in an environment that supports ipv6. """ ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if ubuntu_rel < "trusty": msg = ("IPv6 is not supported in the charms for Ubuntu versions less " "than Trusty 14.04") raise SwiftProxyCharmException(msg) # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. if ubuntu_rel == 'trusty' and os_release('swift-proxy') < 'liberty': add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() openstack_origin = config('openstack-origin') configure_installation_source(openstack_origin) neutron_plugin = config('neutron-plugin') additional_install_locations(neutron_plugin, openstack_origin) add_source(config('extra-source'), config('extra-key')) status_set('maintenance', 'Installing apt packages') apt_update(fatal=True) packages = determine_packages(openstack_origin) apt_install(packages, fatal=True) [open_port(port) for port in determine_ports()] if neutron_plugin == 'midonet': mkdir('/etc/neutron/plugins/midonet', owner='neutron', group='neutron', perms=0o755, force=False)
def install_telegraf(): # Do your setup here. # # If your charm has other dependencies before it can install, # add those as @when() clauses above., or as additional @when() # decorated handlers below # # See the following for information about reactive charms: # # * https://jujucharms.com/docs/devel/developer-getting-started # * https://github.com/juju-solutions/layer-basic#overview # config = hookenv.config() if config['apt_repository'] and config['apt_repository_key']: add_source(config['apt_repository'], config['apt_repository_key']) apt_update() apt_install(config['package_name'], fatal=True) set_state('telegraf.installed')
def setup_ipv6(): """Validate that we can support IPv6 mode. This should be called if prefer-ipv6 is True to ensure that we are running in an environment that supports ipv6. """ ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower() if CompareHostReleases(ubuntu_rel) < "trusty": msg = ("IPv6 is not supported in the charms for Ubuntu versions less " "than Trusty 14.04") raise SwiftProxyCharmException(msg) # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to # use trusty-backports otherwise we can use the UCA. if (ubuntu_rel == 'trusty' and CompareOpenStackReleases(os_release('swift-proxy')) < 'liberty'): add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' 'main') apt_update() apt_install('haproxy/trusty-backports', fatal=True)
def install(): execd_preinstall() for directory in [CONF_FILE_DIR, USR_SHARE_DIR]: hookenv.log("creating config dir at {}".format(directory)) if not os.path.isdir(directory): if os.path.exists(directory): hookenv.log("error: {} exists but is not a directory." " exiting.".format(directory)) return os.mkdir(directory) hookenv.log('adding cloud-installer PPA') add_source('ppa:cloud-installer/simplestreams-testing') apt_update() apt_install(packages=['python-simplestreams', 'python-glanceclient', 'python-yaml', 'python-keystoneclient', 'python-kombu', 'python-swiftclient', 'ubuntu-cloudimage-keyring']) hookenv.log('end install hook.')
def install_java(self): """ Possibly install java. """ java_package = self.options.get("install_java") if not java_package: # noop if we are setting up the openjdk relation. return if lsb_release()['DISTRIB_CODENAME'] == 'trusty': # No Java 8 on trusty fetch.add_source("ppa:openjdk-r/ppa") fetch.apt_update() fetch.apt_install(java_package) java_home_ = java_home() data_changed('java_home', java_home_) # Prime data changed utils.re_edit_in_place('/etc/environment', { r'#? *JAVA_HOME *=.*': 'JAVA_HOME={}'.format(java_home_), }, append_non_matches=True)