Example #1
0
def getNagiosAddress(clusterName):
    # If there is an auto config service exist for the cluster, then we have
    # to use the previously entered nagios server address
    autoConfigService = server_utils.getServiceConfig(GLUSTER_AUTO_CONFIG,
                                                      clusterName)
    if autoConfigService:
        nagiosAddress = autoConfigService['check_command'].split("!")[2]
        return nagiosAddress

    return getHostAddress()
def getNagiosAddress(clusterName):
    # If there is an auto config service exist for the cluster, then we have
    # to use the previously entered nagios server address
    autoConfigService = server_utils.getServiceConfig(GLUSTER_AUTO_CONFIG,
                                                      clusterName)
    if autoConfigService:
        nagiosAddress = autoConfigService['check_command'].split("!")[2]
        return nagiosAddress

    return getHostAddress()
Example #3
0
def findServiceDelta(host):
    serviceDelta = []
    for service in host.get(HOST_SERVICES, []):
        serviceConfig = server_utils.getServiceConfig(
            service['service_description'], service['host_name'])
        if serviceConfig is None:
            service[CHANGE_MODE] = CHANGE_MODE_ADD
            serviceDelta.append(service)
        elif serviceConfig['service_description'] == GLUSTER_AUTO_CONFIG:
            changes = findChangeInAutoConfig(service, serviceConfig)
            if changes:
                serviceDelta.append(changes)
        else:
            changes = findChangeInService(service, serviceConfig)
            if changes:
                serviceDelta.append(changes)
    serviceDelta.extend(findDeletedServices(host))
    return serviceDelta
 def writeService(self, service, hostname):
     if service[CHANGE_MODE] == CHANGE_MODE_ADD:
         serviceModel = Model.Service()
         serviceModel = self.fillModel(serviceModel, service)
         serviceModel.set_filename(self.getCfgFileName(hostname))
         serviceModel[GENERATED_BY_AUTOCONFIG] = 1
         serviceModel.save()
     elif service[CHANGE_MODE] == CHANGE_MODE_REMOVE:
         serviceModel = Model.Service.objects.filter(
             host_name=hostname,
             service_description=service['service_description'])
         if serviceModel:
             serviceModel[0].delete()
     elif service[CHANGE_MODE] == CHANGE_MODE_UPDATE:
         serviceModel = server_utils.getServiceConfig(
             service['service_description'], service['host_name'])
         self.fillModel(serviceModel, service)
         serviceModel.save()
 def writeService(self, service, hostname):
     if service[CHANGE_MODE] == CHANGE_MODE_ADD:
         serviceModel = Model.Service()
         serviceModel = self.fillModel(serviceModel, service)
         serviceModel.set_filename(self.getCfgFileName(hostname))
         serviceModel[GENERATED_BY_AUTOCONFIG] = 1
         serviceModel.save()
     elif service[CHANGE_MODE] == CHANGE_MODE_REMOVE:
         serviceModel = Model.Service.objects.filter(
             host_name=hostname,
             service_description=service['service_description'])
         if serviceModel:
             serviceModel[0].delete()
     elif service[CHANGE_MODE] == CHANGE_MODE_UPDATE:
         serviceModel = server_utils.getServiceConfig(
             service['service_description'], service['host_name'])
         self.fillModel(serviceModel, service)
         serviceModel.save()
def findServiceDelta(host):
    serviceDelta = []
    for service in host.get(HOST_SERVICES, []):
        serviceConfig = server_utils.getServiceConfig(
            service['service_description'], service['host_name'])
        if serviceConfig is None:
            service[CHANGE_MODE] = CHANGE_MODE_ADD
            serviceDelta.append(service)
        elif serviceConfig['service_description'] == GLUSTER_AUTO_CONFIG:
            changes = findChangeInAutoConfig(service, serviceConfig)
            if changes:
                serviceDelta.append(changes)
        else:
            changes = findChangeInService(service, serviceConfig)
            if changes:
                serviceDelta.append(changes)
    serviceDelta.extend(findDeletedServices(host))
    return serviceDelta