Addressed the review comments provided by Liam

This commit is contained in:
viswesn 2016-11-10 23:08:55 +05:30
parent 4c6339e28a
commit 60adafe49b
2 changed files with 4 additions and 139 deletions

View File

@ -7,97 +7,8 @@ import charmhelpers.core.hookenv as hookenv
import charms_openstack.charm
import charms_openstack.ip as os_ip
# import charms_openstack.sdn.odl as odl
# import charms_openstack.sdn.ovs as ovs
RC_FILE = '/root/novarc'
def get_environment(env):
with open("/root/novarc", "r") as ins:
for line in ins:
k, v = line.replace('export', '').replace(" ", "").split('=')
env[k] = v.strip()
return env
def run_command(cmd):
os_env = get_environment(os.environ.copy())
subprocess.check_call(cmd, env=os_env)
def register_endpoints(keystone):
"""When the keystone interface connects, register this unit in the keystone
catalogue.
@param keystone: KeystoneRequires() interface class
@returns: None
"""
charm = MuranoCharm.singleton
keystone.register_endpoints(charm.service_type,
charm.region,
charm.public_url,
charm.internal_url,
charm.admin_url)
def configure_ha_resources(hacluster):
"""Use the singleton from the MuranoCharm to run configure ha resources
@param hacluster: OpenstackHAPeers() interface class
@returns: None
"""
MuranoCharm.singleton.configure_ha_resources(hacluster)
def restart_all():
"""Use the singleton from the MuranoCharm to restart all registered
services
@returns: None
"""
MuranoCharm.singleton.restart_all()
def configure_ssl(keystone=None):
"""Use the singleton from the MuranoCharm to configure ssl
@param keystone: KeystoneRequires() interface class
@returns: None
"""
MuranoCharm.singleton.configure_ssl(keystone)
def update_peers(hacluster):
"""Use the singleton from the MuranoCharm to update peers with detials
of this unit
@param hacluster: OpenstackHAPeers() interface class
@returns: None
"""
MuranoCharm.singleton.update_peers(hacluster)
def assess_status():
"""Just call the MuranoCharm.singleton.assess_status() command to update
status on the unit.
@returns: None
"""
MuranoCharm.singleton.assess_status()
def render_novarc_config(interfaces_list):
"""Use the singleton from the MuranoCharm to run render_novarc_config
@param interfaces_list: List of instances of interface classes.
@returns: None
"""
MuranoCharm.singleton.render_novarc_config(interfaces_list)
def import_io_murano():
"""Use the singleton from the MuranoCharm to run import io-murano
package
@returns: None
"""
MuranoCharm.singleton.import_io_murano()
class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
# Internal name of charm
@ -132,7 +43,6 @@ class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
ha_resources = ['vips', 'haproxy']
sync_cmd = ['murano-db-manage', '--config-file', '/etc/murano/murano.conf', 'upgrade']
def __init__(self, release=None, **kwargs):
@ -144,35 +54,6 @@ class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
release = ch_utils.os_release('python-keystonemiddleware')
super(MuranoCharm, self).__init__(release=release, **kwargs)
def install(self):
"""Customise the installation, configure the source and then call the
parent install() method to install the packages
"""
self.configure_source()
super(MuranoCharm, self).install()
def render_novarc_config(self, interfaces_list):
"""Render novarc config to bootstrap Murano service
@returns None
"""
configs = [RC_FILE]
self.render_with_interfaces(
interfaces_list,
configs=configs)
def import_io_murano(self):
"""Install Core libary io-murano
@returns None
"""
io_murano_lib = "/usr/share/murano-common/io.murano.zip"
if os.path.isfile(io_murano_lib):
cmd = ['murano', 'package-import', io_murano_lib]
run_command(cmd)
def get_amqp_credentials(self):
"""Provide the default amqp username and vhost as a tuple.

View File

@ -14,11 +14,8 @@
import charms_openstack.charm as charm
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
# This charm's library contains all of the handler code associated with
# sdn_charm
import charm.openstack.murano as murano # noqa
#import charm.openstack.murano as murano
charm.use_defaults(
'charm.installed',
@ -43,7 +40,6 @@ def render_config(*args):
with charm.provide_charm_instance() as charm_class:
charm_class.render_with_interfaces(args)
charm_class.assess_status()
murano.render_novarc_config(args)
reactive.set_state('config.rendered')
@ -54,20 +50,8 @@ def init_db():
charm_class.db_sync()
@reactive.when_not('io-murano.imported')
@reactive.when(*COMPLETE_INTERFACE_STATES)
@reactive.when('config.rendered')
def import_io_murano(*args):
murano.import_io_murano()
reactive.set_state('io-murano.imported')
@reactive.when('ha.connected')
def cluster_connected(hacluster):
murano.configure_ha_resources(hacluster)
murano.assess_status()
@reactive.hook('upgrade-charm')
def upgrade_charm():
murano.install()
with charm.provide_charm_instance() as charm_class:
charm_class.configure_ha_resources(hacluster)
charm_class.assess_status()