def assess_status(): '''Assess status of current unit''' application_version_set(get_upstream_version(VERSION_PACKAGE)) moncount = int(config('monitor-count')) units = get_peer_units() # not enough peers and mon_count > 1 if len(units.keys()) < moncount: status_set( 'blocked', 'Insufficient peer units to bootstrap' ' cluster (require {})'.format(moncount)) return # mon_count > 1, peers, but no ceph-public-address ready = sum(1 for unit_ready in units.itervalues() if unit_ready) if ready < moncount: status_set('waiting', 'Peer units detected, waiting for addresses') return # active - bootstrapped + quorum status check if ceph.is_bootstrapped() and ceph.is_quorum(): status_set('active', 'Unit is ready and clustered') else: # Unit should be running and clustered, but no quorum # TODO: should this be blocked or waiting? status_set('blocked', 'Unit not clustered (no quorum)')
def assess_status(): '''Determine status of current unit''' if lxd_running(): status_set('active', 'Unit is ready') else: status_set('blocked', 'LXD is not running') application_version_set(get_upstream_version(VERSION_PACKAGE))
def assess_status(): """Assess status of current unit""" # check to see if the unit is paused. application_version_set(get_upstream_version(VERSION_PACKAGE)) if is_unit_paused_set(): status_set('maintenance', "Paused. Use 'resume' action to resume normal service.") return # Check for mon relation if len(relation_ids('mon')) < 1: status_set('blocked', 'Missing relation: monitor') return # Check for monitors with presented addresses # Check for bootstrap key presentation monitors = get_mon_hosts() if len(monitors) < 1 or not get_conf('osd_bootstrap_key'): status_set('waiting', 'Incomplete relation: monitor') return # Check for OSD device creation parity i.e. at least some devices # must have been presented and used for this charm to be operational running_osds = ceph.get_running_osds() if not running_osds: status_set('blocked', 'No block devices detected using current configuration') else: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds)))
def setup_mds(relation): try: service_restart('ceph-mds') set_state('cephfs.started') application_version_set(get_upstream_version(VERSION_PACKAGE)) except subprocess.CalledProcessError as err: log(message='Error: {}'.format(err), level=ERROR)
def assess_status(configs): """Assess status of current unit Decides what the state of the unit should be based on the current configuration. SIDE EFFECT: calls set_os_workload_status(...) which sets the workload status of the unit. Also calls status_set(...) directly if paused state isn't complete. @param configs: a templating.OSConfigRenderer() object @returns None - this function is executed for its side-effect """ assess_status_func(configs)() if pxc_installed(): # NOTE(fnordahl) ensure we do not call application_version_set with # None argument. New charm deployments will have the meta-package # installed, but upgraded deployments will not. def _possible_packages(): base = determine_packages()[0] yield base if '.' not in base: for i in range(5, 7+1): yield base+'-5.'+str(i) version = None for pkg in _possible_packages(): version = get_upstream_version(pkg) if version is not None: break else: log('Unable to determine installed version for package "{}"' .format(determine_packages()[0]), level=WARNING) return application_version_set(version)
def install_slurm(): hookenv.status_set('maintenance', 'installing slurmdbd packages') packages = [dbd.SLURMDBD_PACKAGE] ch_fetch.apt_install(packages) hookenv.application_version_set( ch_fetch.get_upstream_version(dbd.SLURMDBD_PACKAGE)) flags.set_flag('slurmdbd.installed')
def assess_status(): '''Assess status of current unit''' application_version_set(get_upstream_version(VERSION_PACKAGE)) # Check that the no-bootstrap config option is set in conjunction with # having the bootstrap-source relation established if not config('no-bootstrap') and is_relation_made('bootstrap-source'): status_set( 'blocked', 'Cannot join the bootstrap-source relation when ' 'no-bootstrap is False') return moncount = int(config('monitor-count')) units = get_peer_units() # not enough peers and mon_count > 1 if len(units.keys()) < moncount: status_set( 'blocked', 'Insufficient peer units to bootstrap' ' cluster (require {})'.format(moncount)) return # mon_count > 1, peers, but no ceph-public-address ready = sum(1 for unit_ready in units.values() if unit_ready) if ready < moncount: status_set('waiting', 'Peer units detected, waiting for addresses') return # active - bootstrapped + quorum status check if ceph.is_bootstrapped() and ceph.is_quorum(): status_set('active', 'Unit is ready and clustered') else: # Unit should be running and clustered, but no quorum # TODO: should this be blocked or waiting? status_set('blocked', 'Unit not clustered (no quorum)')
def assess_status(configs): """Assess status of current unit Decides what the state of the unit should be based on the current configuration. SIDE EFFECT: calls set_os_workload_status(...) which sets the workload status of the unit. Also calls status_set(...) directly if paused state isn't complete. @param configs: a templating.OSConfigRenderer() object @returns None - this function is executed for its side-effect """ assess_status_func(configs)() if pxc_installed(): # NOTE(fnordahl) ensure we do not call application_version_set with # None argument. New charm deployments will have the meta-package # installed, but upgraded deployments will not. def _possible_packages(): base = determine_packages()[0] yield base if '.' not in base: for i in range(5, 7 + 1): yield base + '-5.' + str(i) version = None for pkg in _possible_packages(): version = get_upstream_version(pkg) if version is not None: break else: log('Unable to determine installed version for package "{}"'. format(determine_packages()[0]), level=WARNING) return application_version_set(version)
def assess_status(): '''Assess status of current unit''' hookenv.application_version_set(fetch.get_upstream_version(GMETAD)) if host.service_running(GMETAD): hookenv.status_set('active', 'Unit is ready') else: hookenv.status_set('blocked', '{} not running'.format(GMETAD))
def assess_status(): '''Assess status of current unit''' application_version_set(get_upstream_version(VERSION_PACKAGE)) if is_unit_upgrading_set(): status_set( "blocked", "Ready for do-release-upgrade and reboot. " "Set complete when finished.") return # Check that the no-bootstrap config option is set in conjunction with # having the bootstrap-source relation established if not config('no-bootstrap') and is_relation_made('bootstrap-source'): status_set( 'blocked', 'Cannot join the bootstrap-source relation when ' 'no-bootstrap is False') return moncount = int(config('monitor-count')) units = get_peer_units() # not enough peers and mon_count > 1 if len(units.keys()) < moncount: status_set( 'blocked', 'Insufficient peer units to bootstrap' ' cluster (require {})'.format(moncount)) return # mon_count > 1, peers, but no ceph-public-address ready = sum(1 for unit_ready in units.values() if unit_ready) if ready < moncount: status_set('waiting', 'Peer units detected, waiting for addresses') return configured_rbd_features = config('default-rbd-features') if has_rbd_mirrors() and configured_rbd_features: if add_rbd_mirror_features( configured_rbd_features) != configured_rbd_features: # The configured RBD features bitmap does not contain the features # required for RBD Mirroring status_set( 'blocked', 'Configuration mismatch: RBD Mirroring ' 'enabled but incorrect value set for ' '``default-rbd-features``') return # active - bootstrapped + quorum status check if ceph.is_bootstrapped() and ceph.is_quorum(): expected_osd_count = config('expected-osd-count') or 3 if sufficient_osds(expected_osd_count): status_set('active', 'Unit is ready and clustered') else: status_set( 'waiting', 'Monitor bootstrapped but waiting for number of' ' OSDs to reach expected-osd-count ({})'.format( expected_osd_count)) else: # Unit should be running and clustered, but no quorum # TODO: should this be blocked or waiting? status_set('blocked', 'Unit not clustered (no quorum)')
def ovs_vhostuser_client(): ''' Determine whether OVS will act as a client on the vhostuser socket @returns boolean indicating whether OVS will act as a client ''' import apt_pkg ovs_version = get_upstream_version("openvswitch-switch") return apt_pkg.version_compare(ovs_version, '2.9.0') >= 0
def assess_status(): """Assess status of current unit""" # check to see if the unit is paused. application_version_set(get_upstream_version(VERSION_PACKAGE)) if is_unit_upgrading_set(): status_set("blocked", "Ready for do-release-upgrade and reboot. " "Set complete when finished.") return if is_unit_paused_set(): status_set('maintenance', "Paused. Use 'resume' action to resume normal service.") return # Check for mon relation if len(relation_ids('mon')) < 1: status_set('blocked', 'Missing relation: monitor') return # Check for monitors with presented addresses # Check for bootstrap key presentation monitors = get_mon_hosts() if len(monitors) < 1 or not get_conf('osd_bootstrap_key'): status_set('waiting', 'Incomplete relation: monitor') return # Check for vault if use_vaultlocker(): if not relation_ids('secrets-storage'): status_set('blocked', 'Missing relation: vault') return if not vaultlocker.vault_relation_complete(): status_set('waiting', 'Incomplete relation: vault') return # Check for OSD device creation parity i.e. at least some devices # must have been presented and used for this charm to be operational (prev_status, prev_message) = status_get() running_osds = ceph.get_running_osds() if not prev_message.startswith('Non-pristine'): if not running_osds: status_set('blocked', 'No block devices detected using current configuration') else: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds))) else: pristine = True osd_journals = get_journal_devices() for dev in list(set(ceph.unmounted_disks()) - set(osd_journals)): if (not ceph.is_active_bluestore_device(dev) and not ceph.is_pristine_disk(dev)): pristine = False break if pristine: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds)))
def assess_status(): '''Assess status of current unit''' hookenv.application_version_set(fetch.get_upstream_version(GMOND)) if not hookenv.relation_ids("node"): hookenv.status_set('blocked', 'Missing relation to ganglia') return if host.service_running(GMOND): hookenv.status_set('active', 'Unit is ready') else: hookenv.status_set('blocked', '{} not running'.format(GMOND))
def assess_status(): package = mycharm_implementation.package_name() version = fetch.get_upstream_version(package) if version is not None: hookenv.application_version_set(version) # service status if host.service_running(mycharm_implementation.service_name()): hookenv.status_set('active', 'Ready') else: hookenv.status_set('blocked', 'Not running')
def assess_status(): '''Determine status of current unit''' if is_unit_upgrading_set(): status_set('blocked', 'Ready for do-release-upgrade and reboot. ' 'Set complete when finished.') elif lxd_running(): status_set('active', 'Unit is ready') else: status_set('blocked', 'LXD is not running') application_version_set(get_upstream_version(VERSION_PACKAGE))
def install_slurm(): status_set('maintenance', 'installing slurm packages') # Install packages packages = [SLURM_PACKAGE] apt_install(packages) # Set Slurm version application_version_set(get_upstream_version(SLURM_PACKAGE)) set_state('slurm.installed')
def assess_status(): '''Determine status of current unit''' if is_unit_upgrading_set(): status_set( 'blocked', 'Ready for do-release-upgrade and reboot. ' 'Set complete when finished.') elif lxd_running(): status_set('active', 'Unit is ready') else: status_set('blocked', 'LXD is not running') application_version_set(get_upstream_version(VERSION_PACKAGE))
def set_message_hello(): # Set the upstream version of hello for juju status. application_version_set(get_upstream_version('hello')) # Run hello and get the message message = sp.check_output('hello', stderr=sp.STDOUT) # Set the active status with the message status_set('active', message) # Signal that we know the version of hello set_flag('hello.version.set')
def assess_status(configs): """Assess status of current unit Decides what the state of the unit should be based on the current configuration. SIDE EFFECT: calls set_os_workload_status(...) which sets the workload status of the unit. Also calls status_set(...) directly if paused state isn't complete. @param configs: a templating.OSConfigRenderer() object @returns None - this function is executed for its side-effect """ assess_status_func(configs)() application_version_set(get_upstream_version(determine_packages()[0]))
def assess_status(configs): """Assess status of current unit. Decides what the state of the unit should be based on the current configuration. SIDE EFFECT: calls set_os_workload_status(...) which sets the workload status of the unit. Also calls status_set(...) directly if paused state isn't complete. @param configs: a templating.OSConfigRenderer() object @returns None - this function is executed for its side-effect """ assess_status_func(configs)() application_version_set(get_upstream_version(VERSION_PACKAGE))
def assess_status(): """Assess status of current unit""" # check to see if the unit is paused. application_version_set(get_upstream_version(VERSION_PACKAGE)) if is_unit_upgrading_set(): status_set( "blocked", "Ready for do-release-upgrade and reboot. " "Set complete when finished.") return if is_unit_paused_set(): status_set('maintenance', "Paused. Use 'resume' action to resume normal service.") return # Check for mon relation if len(relation_ids('mon')) < 1: status_set('blocked', 'Missing relation: monitor') return # Check for monitors with presented addresses # Check for bootstrap key presentation monitors = get_mon_hosts() if len(monitors) < 1 or not get_conf('osd_bootstrap_key'): status_set('waiting', 'Incomplete relation: monitor') return # Check for vault if use_vaultlocker(): if not relation_ids('secrets-storage'): status_set('blocked', 'Missing relation: vault') return if not vaultlocker.vault_relation_complete(): status_set('waiting', 'Incomplete relation: vault') return # Check for OSD device creation parity i.e. at least some devices # must have been presented and used for this charm to be operational (prev_status, prev_message) = status_get() running_osds = ceph.get_running_osds() if not prev_message.startswith('Non-pristine'): if not running_osds: status_set( 'blocked', 'No block devices detected using current configuration') else: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds)))
def application_version(self): """Return the current version of the application being deployed by the charm, as indicated by the version_package or version_snap attribute """ if os_utils.snap_install_requested(): if not self.version_snap: self.version_snap = self.snaps[0] version = get_snap_version(self.version_snap, fatal=False) if not version: version = os_utils.get_os_codename_install_source( self.config[self.source_config_key]) else: if not self.version_package: self.version_package = self.packages[0] version = fetch.get_upstream_version(self.version_package) if not version: version = os_utils.os_release(self.version_package) return version
def ovs_has_late_dpdk_init(): ''' OVS 2.6.0 introduces late initialization ''' import apt_pkg ovs_version = get_upstream_version("openvswitch-switch") return apt_pkg.version_compare(ovs_version, '2.6.0') >= 0
def get_managment_port(): if get_upstream_version(VERSION_PACKAGE) >= '3': return 15672 else: return 55672
def set_message_mysql_server(): application_version_set(get_upstream_version('mysql-server')) status_set('maintenance', 'Mysql Installed') set_flag('mysql-server.version.set')
def assess_status(): """Assess status of current unit""" # check to see if the unit is paused. application_version_set(get_upstream_version(VERSION_PACKAGE)) if is_unit_upgrading_set(): status_set( "blocked", "Ready for do-release-upgrade and reboot. " "Set complete when finished.") return if is_unit_paused_set(): status_set('maintenance', "Paused. Use 'resume' action to resume normal service.") return # Check for mon relation if len(relation_ids('mon')) < 1: status_set('blocked', 'Missing relation: monitor') return # Check for monitors with presented addresses # Check for bootstrap key presentation monitors = get_mon_hosts() if len(monitors) < 1 or not get_conf('osd_bootstrap_key'): status_set('waiting', 'Incomplete relation: monitor') return # Check for vault if use_vaultlocker(): if not relation_ids('secrets-storage'): status_set('blocked', 'Missing relation: vault') return try: if not vaultlocker.vault_relation_complete(): status_set('waiting', 'Incomplete relation: vault') return except Exception as e: status_set('blocked', "Warning: couldn't verify vault relation") log("Exception when verifying vault relation - maybe it was " "offline?:\n{}".format(str(e))) log("Traceback: {}".format(traceback.format_exc())) # Check for OSD device creation parity i.e. at least some devices # must have been presented and used for this charm to be operational (prev_status, prev_message) = status_get() running_osds = ceph.get_running_osds() if not prev_message.startswith('Non-pristine'): if not running_osds: status_set( 'blocked', 'No block devices detected using current configuration') else: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds))) else: pristine = True osd_journals = get_journal_devices() for dev in list(set(ceph.unmounted_disks()) - set(osd_journals)): if (not ceph.is_active_bluestore_device(dev) and not ceph.is_pristine_disk(dev)): pristine = False break if pristine: status_set('active', 'Unit is ready ({} OSD)'.format(len(running_osds))) try: get_bdev_enable_discard() except ValueError as ex: status_set('blocked', str(ex)) try: bluestore_compression = ch_context.CephBlueStoreCompressionContext() bluestore_compression.validate() except ValueError as e: status_set('blocked', 'Invalid configuration: {}'.format(str(e)))
def ovs_has_late_dpdk_init(): ''' OVS 2.6.0 introduces late initialization ''' import apt_pkg ovs_version = get_upstream_version("openvswitch-switch") return apt_pkg.version_compare(ovs_version, '2.6.0') >= 0