Skip to content

Commit

Permalink
[sunbeam] Update plugin to collet more details
Browse files Browse the repository at this point in the history
* Add juju related info for sunbeam
* Add logs from the sunbeam snap home user

Resolves: SET-682

Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
arif-ali committed May 19, 2024
1 parent 11879fb commit 24c32b1
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion sos/report/plugins/sunbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#
# See the LICENSE file in the source distribution for further information.

from sos.report.plugins import Plugin, UbuntuPlugin
import json
from sos.report.plugins import Plugin, UbuntuPlugin, PluginOpt


class Sunbeam(Plugin, UbuntuPlugin):
Expand All @@ -19,6 +20,11 @@ class Sunbeam(Plugin, UbuntuPlugin):

common_dir = '/var/snap/openstack/common'

option_list = [
PluginOpt('sunbeam-user', default='ubuntu', val_type=str,
desc='The user used for sunbeam installation')
]

def setup(self):

self.add_service_status('snap.openstack.*')
Expand All @@ -37,6 +43,38 @@ def setup(self):
'sunbeam cluster list --format yaml',
])

sunbeam_user = self.get_option("sunbeam-user")

cmd_pre = f"su - {sunbeam_user} -c"
res = self.exec_cmd(f'{cmd_pre} "sunbeam utils juju-login"')
if res['status'] == 0:

self.add_cmd_output(f'{cmd_pre} "juju models"')

juju_models = self.collect_cmd_output(
f'{cmd_pre} "juju models --format json"')

if juju_models['status'] == 0:
juju_status_json = json.loads(juju_models['output'])

for model in juju_status_json['models']:

self.add_cmd_output([
f'{cmd_pre} "juju status -m {model["name"]}"',
f'{cmd_pre} "juju status -m {model["name"]} '
'--format json"',
])

user_getent = self.exec_cmd(f"getent passwd {sunbeam_user}")
sb_user_homedir = user_getent["output"].split(":")[5]
sb_snap_homedir = f'{sb_user_homedir}/snap/openstack/common'

self.add_copy_spec([
f"{sb_snap_homedir}/*.log",
f"{sb_snap_homedir}/etc/*/*.log",
f"{sb_snap_homedir}/logs/*.log",
])

def postproc(self):

self.do_file_private_sub(
Expand Down

0 comments on commit 24c32b1

Please sign in to comment.