Exemplo n.º 1
0
    def add_maintenance_service(name, backend_guid, abm_name):
        """
        Add a maintenance service with a specific name
        :param name: Name of the service to add
        :type name: str
        :param backend_guid: Backend for which the maintenance service needs to run
        :type backend_guid: str
        :param abm_name: Name of the ABM cluster
        :type abm_name: str
        """
        if ServiceManager.has_service(name, MaintenanceController._local_client):
            if not ServiceManager.is_enabled(name, MaintenanceController._local_client):
                ServiceManager.enable_service(name, MaintenanceController._local_client)
        else:
            config_location = '/ovs/alba/backends/{0}/maintenance/config'.format(backend_guid)
            alba_config = 'etcd://127.0.0.1:2379{0}'.format(config_location)
            params = {'ALBA_CONFIG': alba_config}
            EtcdConfiguration.set(config_location, json.dumps({
                'log_level': 'info',
                'albamgr_cfg_url': 'etcd://127.0.0.1:2379/ovs/arakoon/{0}/config'.format(abm_name)
            }, indent=4), raw=True)

            ServiceManager.add_service(name='alba-maintenance', client=MaintenanceController._local_client,
                                       params=params, target_name=name)
        ServiceManager.start_service(name, MaintenanceController._local_client)