def set_status(data):
    logging.debug('enter set status')
    try:
        service = Service.get(name=data['service'])
        logging.debug(service)
        try:
            status = ServiceStatus(
                service=service,
                date_added=datetime.now(),
                description=data.get('description', ''),
                running=data['running'],
                status_string=data['status_string']
            )
        except:
            status = ServiceStatus(
                service=service,
                date_added=datetime.now(),
                description=data.description,
                running=data.running,
                status_string=data.status_string
            )
        status.save()
        return 'Successfully Created'
    except Exception as e:
        logging.debug(str(e))
        return str(e)
Exemplo n.º 2
0
def form_get_services_options(request):
    try:
        if request.is_authenticated:
            return [{'value': service.name, 'label': service.name} for service in Service.filter()]
        else:
            return HttpResponseForbidden
    except:
        return HttpResponseBadRequest
Exemplo n.º 3
0
def form_get_services(request):
    try:
        if request.is_authenticated:
            return Service.filter()
        else:
            return HttpResponseForbidden
    except:
        return HttpResponseBadRequest
def get_info(service=None, display=False):
    if service is None:
        # get info for all services
        return_data = []
        services = Service.filter()
        for service in services:
            data = {'service': service.get_json(), 'statuses': []}
            if display:
                data['statuses'] = service.get_last_4_days()
            else:
                statuses = ServiceStatus.filter(service=service)
                for s in statuses:
                    data['statuses'].append(s.get_json())
            return_data.append(data)
        return return_data
    else:
        service = Service.get(name=service)
        statuses = ServiceStatus.filter(service=service)
        return_data = {'service': service.get_json(), 'statuses': []}
        for s in statuses:
            return_data['statuses'].append(s.get_json())
        return return_data
def create_service(data):
    logging.debug('enter create service')
    logging.debug(type(data))
    try:
        try:
            service = Service(
                name=data['name'],
                description=data.get('description', ''),
                date_added=datetime.now()
            )
        except:
            service = Service(
                name=data.name,
                description=data.description,
                date_added=datetime.now()
            )
        service.save()
        logging.debug(service)
        return 'Successfully Created'
    except Exception as e:
        logging.debug(str(e))
        return str(e)
 def action(self):
     all_services = Service.filter()
     for service in all_services:
         if service.is_url():
             service.do_monitor = True
             service.save()
Exemplo n.º 7
0
def get_services(request):
    return Service.filter()