Merge juju-bmc:juju-bmc-strict into juju-bmc:master

Proposed by Jose Guedez
Status: Merged
Approved by: Jose Guedez
Approved revision: 8386ac9ee8cb2cb711bcd7c93a2b3250de406aee
Merged at revision: 6ddecd86f6b22d2ab31cf7a30507a6789cd27471
Proposed branch: juju-bmc:juju-bmc-strict
Merge into: juju-bmc:master
Diff against target: 126 lines (+54/-14)
4 files modified
juju-bmc/__init__.py (+0/-0)
juju-bmc/juju-bmc (+21/-7)
setup.py (+17/-0)
snap/snapcraft.yaml (+16/-7)
Reviewer Review Type Date Requested Status
Joe Guo (community) Approve
Canonical IS CREs Pending
Review via email: mp+385169@code.launchpad.net

Commit message

add support for strict snap confinement

Description of the change

Add support for strict snap confinement

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joe Guo (guoqiao) :
Revision history for this message
Jose Guedez (jfguedez) wrote :

replied to comment inline

Revision history for this message
Joe Guo (guoqiao) wrote :

LGTM, +1.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 6ddecd86f6b22d2ab31cf7a30507a6789cd27471

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/juju-bmc/__init__.py b/juju-bmc/__init__.py
0new file mode 1006440new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/juju-bmc/__init__.py
diff --git a/src/juju-bmc b/juju-bmc/juju-bmc
1similarity index 85%1similarity index 85%
2rename from src/juju-bmc2rename from src/juju-bmc
3rename to juju-bmc/juju-bmc3rename to juju-bmc/juju-bmc
index 5194ff4..70a1953 100755
--- a/src/juju-bmc
+++ b/juju-bmc/juju-bmc
@@ -35,6 +35,9 @@ import logging
35import os35import os
36import subprocess36import subprocess
3737
38from juju.model import Model
39from juju import loop
40
38# `__name__` will show `__main__`41# `__name__` will show `__main__`
39LOG = logging.getLogger('juju-bmc')42LOG = logging.getLogger('juju-bmc')
4043
@@ -72,6 +75,23 @@ def parse_args():
72 return parser.parse_args()75 return parser.parse_args()
7376
7477
78async def get_machine_instance_id(machine_id):
79 """
80 Connects to the juju controller using default credentials in $HOME
81 to obtain the instance id of the provided machine_id
82 """
83 # connect to the current juju controller/model
84 model = Model()
85 await model.connect()
86
87 machine = model.machines.get(machine_id)
88 if not machine:
89 LOG.error('juju machine %s not found, exit', machine_id)
90 sys.exit(-1)
91
92 return machine.data["instance-id"]
93
94
75def main():95def main():
76 args = parse_args()96 args = parse_args()
7797
@@ -86,13 +106,7 @@ def main():
86106
87 # machine_id --> instance_id/system_id107 # machine_id --> instance_id/system_id
88 machine_id = str(args.machine_id)108 machine_id = str(args.machine_id)
89 cmd = ['juju', 'show-machine', machine_id, '--format', 'json']109 instance_id = loop.run(get_machine_instance_id(machine_id))
90 data = json.loads(get_cmd_output(cmd))
91 machines = data['machines']
92 if not machines:
93 LOG.error('juju machine %s not found, exit', machine_id)
94 sys.exit(-1)
95 instance_id = machines[str(machine_id)]['instance-id']
96 LOG.info('find juju instance-id(maas system_id) for machine %s: %s', machine_id, instance_id)110 LOG.info('find juju instance-id(maas system_id) for machine %s: %s', machine_id, instance_id)
97111
98 # find maas api name112 # find maas api name
diff --git a/setup.py b/setup.py
99new file mode 100644113new file mode 100644
index 0000000..3dd7f92
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,17 @@
1#!/usr/bin/env python3
2
3from setuptools import setup, find_packages
4
5setup(
6 name='juju-bmc',
7 version='0.11',
8 url='https://launchpad.net/juju-bmc',
9 author='Canonical Bootstack',
10 author_email="bootstack@canonical.com",
11 description="juju plugin that adds a command to access a server out band management",
12 packages=find_packages(),
13 install_requires=['juju >= 2.8.1'],
14 scripts=[
15 "juju-bmc/juju-bmc",
16 ],
17)
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 866e08f..0522094 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -8,21 +8,30 @@ description: |
8 and establishes a connection to the BMC console of a bare metal server.8 and establishes a connection to the BMC console of a bare metal server.
99
10grade: devel # must be 'stable' to release into candidate/stable channels10grade: devel # must be 'stable' to release into candidate/stable channels
11confinement: devmode # use 'strict' once you have the right plugs and slots11confinement: strict
12
13plugs:
14 config-files:
15 interface: personal-files
16 read:
17 - $HOME/.maascli.db
18 - $HOME/.local/share/juju
19 write:
20 - $HOME/.maascli.db
1221
13apps:22apps:
14 juju-bmc:23 juju-bmc:
15 command: bin/juju-bmc24 command: bin/juju-bmc
25 plugs:
26 - network
27 - config-files
28 - ssh-keys
1629
17parts:30parts:
18 juju-bmc:31 juju-bmc:
19 plugin: dump32 plugin: python
20 source: ./src33 source: ./
21 organize:
22 juju-bmc: bin/
23 stage-packages:34 stage-packages:
24 - maas-cli35 - maas-cli
25 - ipmitool36 - ipmitool
26 - sshpass37 - sshpass
27 stage-snaps:
28 - juju/latest/stable

Subscribers

People subscribed via source and target branches

to all changes: