예제 #1
0
def get_devices():
    """
    this is frequently called internally by index.html's javascript
    it returns a json dump of all containers and devices 
    """
    containers_devices = db_session.query(Container.ip_addr, Device.serial_number).all()
    return json.dumps(containers_devices)
예제 #2
0
파일: util.py 프로젝트: ehrenb/PuppetMaster
def get_jsonrpc_server_instance_device(serial_number):
    """
    Build jsonrpc server instance by querying to find the container related to
    the serial_number
    """
    containers_devices = db_session.query(Container.ip_addr, Container.port).filter(Device.serial_number == serial_number).first()
    if containers_devices:
        rpc_ip_addr = containers_devices[0]
        rpc_port = containers_devices[1]
        return get_jsonrpc_server_instance(rpc_ip_addr, rpc_port), rpc_ip_addr, rpc_port
    return None, None, None