Add package install capability
This commit is contained in:
parent
8e3a5cc0cc
commit
0c2b748ead
|
@ -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()
|
||||
|
|
|
@ -9,6 +9,7 @@ tags:
|
|||
subordinate: true
|
||||
series:
|
||||
- xenial
|
||||
- bionic
|
||||
provides:
|
||||
neutron-plugin-api-subordinate:
|
||||
interface: neutron-plugin-api-subordinate
|
||||
|
|
|
@ -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…
Reference in New Issue