Use aliases and include a module name when obtaining a logger
This commit is contained in:
parent
e4cfb975aa
commit
f203311d46
@ -37,7 +37,7 @@ UCA_CODENAME_MAP = {
|
|||||||
|
|
||||||
|
|
||||||
_releases = {}
|
_releases = {}
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class OSBaseCharm(CharmBase):
|
class OSBaseCharm(CharmBase):
|
||||||
@ -63,10 +63,10 @@ class OSBaseCharm(CharmBase):
|
|||||||
|
|
||||||
def on_install(self, event):
|
def on_install(self, event):
|
||||||
logging.info("Installing packages")
|
logging.info("Installing packages")
|
||||||
if self.framework.model.config.get('source'):
|
if self.model.config.get('source'):
|
||||||
add_source(
|
add_source(
|
||||||
self.framework.model.config['source'],
|
self.model.config['source'],
|
||||||
self.framework.model.config.get('key'))
|
self.model.config.get('key'))
|
||||||
apt_update(fatal=True)
|
apt_update(fatal=True)
|
||||||
apt_install(self.PACKAGES, fatal=True)
|
apt_install(self.PACKAGES, fatal=True)
|
||||||
self.update_status()
|
self.update_status()
|
||||||
@ -74,25 +74,25 @@ class OSBaseCharm(CharmBase):
|
|||||||
def update_status(self):
|
def update_status(self):
|
||||||
logging.info("Updating status")
|
logging.info("Updating status")
|
||||||
if self.state.series_upgrade:
|
if self.state.series_upgrade:
|
||||||
self.model.unit.status = BlockedStatus(
|
self.unit.status = BlockedStatus(
|
||||||
'Ready for do-release-upgrade and reboot. '
|
'Ready for do-release-upgrade and reboot. '
|
||||||
'Set complete when finished.')
|
'Set complete when finished.')
|
||||||
return
|
return
|
||||||
if self.state.is_paused:
|
if self.state.is_paused:
|
||||||
self.model.unit.status = MaintenanceStatus(
|
self.unit.status = MaintenanceStatus(
|
||||||
"Paused. Use 'resume' action to resume normal service.")
|
"Paused. Use 'resume' action to resume normal service.")
|
||||||
missing_relations = []
|
missing_relations = []
|
||||||
for relation in self.REQUIRED_RELATIONS:
|
for relation in self.REQUIRED_RELATIONS:
|
||||||
if not self.framework.model.get_relation(relation):
|
if not self.model.get_relation(relation):
|
||||||
missing_relations.append(relation)
|
missing_relations.append(relation)
|
||||||
if missing_relations:
|
if missing_relations:
|
||||||
self.model.unit.status = BlockedStatus(
|
self.unit.status = BlockedStatus(
|
||||||
'Missing relations: {}'.format(', '.join(missing_relations)))
|
'Missing relations: {}'.format(', '.join(missing_relations)))
|
||||||
return
|
return
|
||||||
if self.state.is_started:
|
if self.state.is_started:
|
||||||
self.model.unit.status = ActiveStatus('Unit is ready')
|
self.unit.status = ActiveStatus('Unit is ready')
|
||||||
else:
|
else:
|
||||||
self.model.unit.status = WaitingStatus('Not ready for reasons')
|
self.unit.status = WaitingStatus('Not ready for reasons')
|
||||||
logging.info("Status updated")
|
logging.info("Status updated")
|
||||||
|
|
||||||
def on_update_status(self, event):
|
def on_update_status(self, event):
|
||||||
|
Loading…
Reference in New Issue
Block a user