Browse Source

Add package install capability

changes/73/738573/1
Aymen Frikha 3 years ago
parent
commit
0c2b748ead
  1. 19
      src/lib/charm/openstack/neutron_arista.py
  2. 1
      src/metadata.yaml
  3. 6
      src/reactive/neutron_arista_handlers.py

19
src/lib/charm/openstack/neutron_arista.py

@ -1,12 +1,21 @@
#!/usr/bin/env python
from collections import OrderedDict
from charmhelpers.core.hookenv import config
from charmhelpers.core.hookenv import (
config,
log
)
import charms_openstack.charm
from charmhelpers.contrib.openstack import (
context,
templating,
)
from charmhelpers.fetch import (
apt_install,
apt_update,
filter_installed_packages,
add_source,
)
from charmhelpers.contrib.openstack.utils import os_release
@ -25,6 +34,14 @@ class NeutronAristaCharm(charms_openstack.charm.OpenStackCharm):
# List of packages to install for this charm
packages = ['python-networking-arista']
def install(self):
log('Starting arista 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)
def write_config(self):
configs = self.register_configs()
configs.write_all()

1
src/metadata.yaml

@ -9,6 +9,7 @@ tags:
subordinate: true
series:
- xenial
- bionic
provides:
neutron-plugin-api-subordinate:
interface: neutron-plugin-api-subordinate

6
src/reactive/neutron_arista_handlers.py

@ -26,6 +26,12 @@ import charm.openstack.neutron_arista as arista # noqa
use_defaults('update-status')
@reactive.when_not('arista-package.installed')
@reactive.when('neutron-plugin-api-subordinate.available')
def install_arista():
with provide_charm_instance() as charm_class:
charm_class.install()
reactive.set_state('arista-package.installed')
@reactive.when('neutron-plugin-api-subordinate.connected')
def configure_principle(api_principle):

Loading…
Cancel
Save