Esempio n. 1
0
def manage():
    manager = ServiceManager([
        {
            'service': 'cf-webadmin',
            'ports': [8070],  # ports to after start
            'provided_data': [
                #helpers.HttpRelation()
            ],
            'required_data': [
                OrchestratorRelation(),
                MysqlRelation(),
                NatsRelation(),
                UAARelation(),
                CloudControllerDBRelation(),
                # UAADBRelation(),
            ],
            'data_ready': [
                actions.setup_uaac_client,
                actions.render_webadmin_config,
                helpers.render_template(
                    source='upstart.conf',
                    target='/etc/init/cf-webadmin.conf'),
            ],
        },
    ])
    manager.manage()
Esempio n. 2
0
def manage():
    config = hookenv.config()
    release = os_release('neutron-common')
    manager = ServiceManager([
        # onos services setup
        {
            'service': 'onos-setup',
            'data_ready': [
                onos_package.install_packages,
            ],
            'provided_data': [
                onos_relation.BuildSDNRelation(),
            ],
        },
        {
            'service': 'api-render',
            'required_data': [
                onos_relation.ONOSControllerRelation(),
                config,
                onos_relation.ConfigTranslation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='ml2_conf.ini',
                    template_loader=get_loader('templates/', release),
                    target='/etc/neutron/plugins/ml2/ml2_conf.ini',
                    on_change_action=(partial(remote_restart,
                                              'neutron-plugin-api-subordinate',
                                              'neutron-server')),
                ),
            ],
        },
    ])
    manager.manage()
Esempio n. 3
0
def manage():
    config = hookenv.config()
    release = os_release('neutron-common')
    manager = ServiceManager([
        # onos services setup
        {
            'service': 'onos-setup',
            'data_ready': [
                onos_package.install_packages,
            ],
            'provided_data': [
                onos_relation.BuildSDNRelation(),
            ],
        },
        {
            'service':
            'api-render',
            'required_data': [
                onos_relation.ONOSControllerRelation(),
                config,
                onos_relation.ConfigTranslation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='ml2_conf.ini',
                    template_loader=get_loader('templates/', release),
                    target='/etc/neutron/plugins/ml2/ml2_conf.ini',
                    on_change_action=(partial(
                        remote_restart, 'neutron-plugin-api-subordinate',
                        'neutron-server')),
                ),
            ],
        },
    ])
    manager.manage()
Esempio n. 4
0
def manage():
    config = hookenv.config()
    release = os_release('neutron-common')
    manager = ServiceManager([
        # Actions which have no prerequisites and can be rerun
        {
            'service': 'odl-setup',
            'data_ready': [
                odl_utils.install_packages,
            ],
            'provided_data': [
                odl_data.NeutronApiSDNRelation(),
            ],
        },
        {
            'service': 'api-render',
            'required_data': [
                odl_data.ODLControllerRelation(),
                config,
                odl_data.ConfigTranslation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='ml2_conf.ini',
                    template_loader=get_loader('templates/', release),
                    target='/etc/neutron/plugins/ml2/ml2_conf.ini',
                    on_change_action=(partial(remote_restart,
                                              'neutron-plugin-api-subordinate',
                                              'neutron-server')),
                ),
            ]
        },
    ])
    manager.manage()
Esempio n. 5
0
def manage():
    manager = ServiceManager([
        {
            'service':
            'solr',
            'ports': [8983],  # ports to after start
            'provided_data': [
                # context managers for provided relations
                # e.g.: helpers.HttpRelation()
                helpers.HttpRelation()
            ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
                helpers.RelationContext('zookeeper',
                                        ['private-address', 'port'])
            ],
            'data_ready': [
                actions.configure_solr,
                actions.log_start,
            ],
        },
    ])
    manager.manage()
Esempio n. 6
0
def manage():
    status_set('maintenance', 'starting')
    config = hookenv.config()
    manager = ServiceManager([
        {
            'service': 'nrpe-install',
            'data_ready': [
                nrpe_utils.install_packages,
                nrpe_utils.install_charm_files,
            ],
            'start': [],
            'stop': [],
        },
        {
            'service': 'nrpe-config',
            'required_data': [
                config,
                nrpe_helpers.MonitorsRelation(),
                nrpe_helpers.PrincipalRelation(),
                nrpe_helpers.NagiosInfo(),
            ],
            'data_ready': [
                nrpe_utils.update_nrpe_external_master_relation,
                nrpe_utils.update_monitor_relation,
                nrpe_utils.create_host_export_fragment,
                nrpe_utils.render_nrped_files,
                helpers.render_template(
                    source='nrpe.tmpl',
                    target='/etc/nagios/nrpe.cfg'
                ),
            ],
            'provided_data': [nrpe_helpers.PrincipalRelation()],
            'ports': [hookenv.config('server_port'), 'ICMP'],
            'start': [nrpe_utils.maybe_open_ports, nrpe_utils.restart_nrpe],
            'stop': [],
        },
        {
            'service': 'nrpe-rsync',
            'required_data': [
                config,
                nrpe_helpers.PrincipalRelation(),
                nrpe_helpers.RsyncEnabled(),
                nrpe_helpers.NagiosInfo(),
            ],
            'data_ready': [
                nrpe_utils.remove_host_export_fragments,
                helpers.render_template(
                    source='rsync-juju.d.tmpl',
                    target='/etc/rsync-juju.d/010-nrpe-external-master.conf'
                ),
                nrpe_utils.create_host_export_fragment,
            ],
            'start': [nrpe_utils.restart_rsync],
            'stop': [],
        },
    ])
    manager.manage()
    status_set('active', 'ready')
Esempio n. 7
0
def manage():
    config = hookenv.config()
    manager = ServiceManager([
        {
            'service':
            'thruk-master',
            'ports': [80, 443],  # ports to after start
            # 'provided_data': [
            #    # context managers for provided relations
            #    # e.g.: helpers.HttpRelation()
            # ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
                thruk_helpers.ThrukMasterRelation(),
                helpers.RequiredConfig(),
            ],
            'data_ready': [
                helpers.render_template(source='thruk_local.conf',
                                        target='/etc/thruk/thruk_local.conf'),
                helpers.render_template(source='log4perl.conf',
                                        target='/etc/thruk/log4perl.conf'),
                actions.log_start,
                actions.update_ppa,
                actions.thruk_set_password,
                actions.thruk_fix_ssl,
            ],
        },
        {
            'service':
            'thruk-monitoring',
            'required_data': [
                thruk_helpers.NEMRelation(),
                helpers.RequiredConfig(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='thruk-nrpe.j2',
                    target='/etc/nagios/nrpe.d/check_{}.cfg'.format(
                        hookenv.local_unit().replace('/', '-'), )),
                helpers.render_template(
                    source='thruk-nagios.j2',
                    target='/var/lib/nagios/export/service__{}-{}.cfg'.format(
                        config['nagios_context'],
                        hookenv.local_unit().replace('/', '-'),
                    )),
            ],
        },
    ])
    manager.manage()
Esempio n. 8
0
def manage():
    services = [
        {
            'service': 'bird',
            'ports': [9905, 9906],
            'provided_data': [
                relations.BgpRRRelation(),
            ],
            'required_data': [
                relations.BgpRRRelation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='bird.conf',
                    target='/etc/bird/bird.conf'),
                actions.log_start,
            ],
        },
    ]

    # If we're using IPv6, start using BIRD.
    if config('enable-ipv6'):
        services.append({
            'service': 'bird6',
            'ports': [9905, 9906],
            'provided_data': [
                relations.BgpRRRelation(),
            ],
            'required_data': [
                relations.BgpRRRelation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='bird6.conf',
                    target='/etc/bird/bird6.conf'),
                actions.log_start,
            ],
        })

    manager = ServiceManager(services)
    manager.manage()
def manage():
    manager = ServiceManager([
        {
            'service': 'keepalived',
            'required_data': [
                helpers.RequiredConfig('virtual-ip',
                                       'router-id'),
                {'is_leader': hookenv.is_leader()}
            ],
            'data_ready': [
                actions.log_start,
                helpers.template(
                    source='keepalived.conf',
                    target=KEEPALIVED_CONFIG_FILE,
                    perms=0o644
                )
            ],
            # keepalived has no "status" command
            'stop': [
                lambda arg: host.service_stop('keepalived')
            ],
            'start': [
                lambda arg: host.service_restart('keepalived')
            ],
        },
        {
            'service': 'procps',
            'required_data': [
                {'sysctl': {'net.ipv4.ip_nonlocal_bind': 1}},
            ],
            'data_ready': [
                helpers.template(
                    source='50-keepalived.conf',
                    target=SYSCTL_FILE,
                    perms=0o644
                )
            ],
        }
    ])
    manager.manage()
Esempio n. 10
0
def manage():
    manager = ServiceManager(
        [
            {
                "service": "solr",
                "ports": [8983],  # ports to after start
                "provided_data": [
                    # context managers for provided relations
                    # e.g.: helpers.HttpRelation()
                    helpers.HttpRelation()
                ],
                "required_data": [
                    # data (contexts) required to start the service
                    # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                    #       helpers.MysqlRelation(),
                    helpers.RelationContext("zookeeper", ["private-address", "port"])
                ],
                "data_ready": [actions.configure_solr, actions.log_start],
            }
        ]
    )
    manager.manage()
Esempio n. 11
0
def manage():
    manager = ServiceManager([
        {
            'service':
            'keepalived',
            'required_data': [
                helpers.RequiredConfig('virtual-ip', 'router-id'), {
                    'is_leader': hookenv.is_leader()
                }
            ],
            'data_ready': [
                actions.log_start,
                helpers.template(source='keepalived.conf',
                                 target=KEEPALIVED_CONFIG_FILE,
                                 perms=0o644)
            ],
            # keepalived has no "status" command
            'stop': [lambda arg: host.service_stop('keepalived')],
            'start': [lambda arg: host.service_restart('keepalived')],
        },
        {
            'service':
            'procps',
            'required_data': [
                {
                    'sysctl': {
                        'net.ipv4.ip_nonlocal_bind': 1
                    }
                },
            ],
            'data_ready': [
                helpers.template(source='50-keepalived.conf',
                                 target=SYSCTL_FILE,
                                 perms=0o644)
            ],
        }
    ])
    manager.manage()
Esempio n. 12
0
def manage():
    manager = ServiceManager([
        {
            'service':
            'basecharm',
            'ports': [],  # ports to after start
            'provided_data': [
                # context managers for provided relations
                # e.g.: helpers.HttpRelation()
            ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
            ],
            'data_ready': [
                helpers.render_template(source='upstart.conf',
                                        target='/etc/init/basecharm'),
                actions.log_start,
            ],
        },
    ])
    manager.manage()
Esempio n. 13
0
def manage():
    manager = ServiceManager(
        [
            {
                "service": "vanilla",
                "ports": [],  # ports to after start
                "provided_data": [
                    # context managers for provided relations
                    # e.g.: helpers.HttpRelation()
                ],
                "required_data": [
                    # data (contexts) required to start the service
                    # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                    #       helpers.MysqlRelation(),
                ],
                "data_ready": [
                    helpers.render_template(source="upstart.conf", target="/etc/init/vanilla"),
                    actions.log_start,
                ],
            }
        ]
    )
    manager.manage()
Esempio n. 14
0
def manage():
    manager = ServiceManager([
        {
            'service': 'saiku',
            'ports': [],  # ports to after start
            'provided_data': [
                # context managers for provided relations
                # e.g.: helpers.HttpRelation()
            ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
            ],
            'data_ready': [
                helpers.render_template(
                    source='upstart.conf',
                    target='/etc/init/saiku'),
                actions.log_start,
            ],
        },
    ])
    manager.manage()
Esempio n. 15
0
def manage():
    manager = ServiceManager([
        {
            'service': 'qdbd',
            'ports': [ 2836 ],  # ports to after start
            'provided_data': [
                # context managers for provided relations
                # e.g.: helpers.HttpRelation()
            ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
            ],
            'data_ready': [
                actions.log_start,
            ],
        },
        {
            'service': 'qdb_httpd',
            'ports': [ 8080 ],  # ports to after start
            'provided_data': [
                # context managers for provided relations
                # e.g.: helpers.HttpRelation()
            ],
            'required_data': [
                # data (contexts) required to start the service
                # e.g.: helpers.RequiredConfig('domain', 'auth_key'),
                #       helpers.MysqlRelation(),
            ],
            'data_ready': [
                actions.log_start,
            ],
        },
    ])
    manager.manage()
Esempio n. 16
0
def manage():
    """Manage nrpe service."""
    status_set("maintenance", "starting")
    config = hookenv.config()
    manager = ServiceManager([
        {
            "service":
            "nrpe-install",
            "data_ready": [
                nrpe_utils.install_packages,
                nrpe_utils.install_charm_files,
            ],
            "start": [],
            "stop": [],
        },
        {
            "service":
            "nrpe-config",
            "required_data": [
                config,
                nrpe_helpers.MonitorsRelation(),
                nrpe_helpers.PrincipalRelation(),
                nrpe_helpers.NagiosInfo(),
            ],
            "data_ready": [
                nrpe_utils.update_nrpe_external_master_relation,
                nrpe_utils.update_monitor_relation,
                nrpe_utils.create_host_export_fragment,
                nrpe_utils.render_nrped_files,
                helpers.render_template(source="nrpe.tmpl",
                                        target="/etc/nagios/nrpe.cfg"),
            ],
            "provided_data": [nrpe_helpers.PrincipalRelation()],
            "ports": [hookenv.config("server_port"), "ICMP"],
            "start": [nrpe_utils.maybe_open_ports, nrpe_utils.restart_nrpe],
            "stop": [],
        },
        {
            "service":
            "nrpe-rsync",
            "required_data": [
                config,
                nrpe_helpers.PrincipalRelation(),
                nrpe_helpers.RsyncEnabled(),
                nrpe_helpers.NagiosInfo(),
            ],
            "data_ready": [
                nrpe_utils.remove_host_export_fragments,
                helpers.render_template(
                    source="rsync-juju.d.tmpl",
                    target="/etc/rsync-juju.d/010-nrpe-external-master.conf",
                ),
                nrpe_utils.create_host_export_fragment,
            ],
            "start": [nrpe_utils.restart_rsync],
            "stop": [],
        },
    ])
    manager.manage()
    if nrpe_utils.has_consumer():
        status_set("active", "ready")
    else:
        status_set("blocked", "Nagios server not configured or related")