Exemple #1
0
def deploy(name, zipfile):
    print 'deploying %s to sensor %s ...' % (zipfile, name),
    
    # Read file 
    f = open(zipfile, 'rb')
    ba = f.read()
    f.close()

    # Deploy sensor
    transport, client = connect.openClient()    
    client.deploySensor(name, ba); 
    connect.closeClient(transport)
    
    print '[OK]'
Exemple #2
0
def deploy(name, zipfile):
    print 'deploying %s to sensor %s ...' % (zipfile, name),

    # Read file
    f = open(zipfile, 'rb')
    ba = f.read()
    f.close()

    # Deploy sensor
    transport, client = connect.openClient()
    client.deploySensor(name, ba)
    connect.closeClient(transport)

    print '[OK]'
Exemple #3
0
def configure(sensor, path):
    conf = os.path.join(path, 'conf.yaml')
    if os.path.exists(conf):
        # Reading yaml file
        yf = open(conf, 'r')
        content = yaml.load(yf)
        yf.close()

        config = ttypes.SensorConfiguration()
        if 'interval' in content:
            config.interval = int(content['interval'])

        if 'sensorType' in content:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES[
                content['sensorType']]
        else:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES['METRIC']

        parameters = []
        if 'params' in content:
            for key in content['params'].keys():
                param = ttypes.Parameter()
                param.key = key
                param.value = str(content['params'][key])
                parameters.append(param)
        config.parameters = parameters

        # Connect with management interface
        transport, client = connect.openClient()

        # Update configuration
        client.updateSensorConfiguration(sensor, config, [])

        # Close transport
        connect.closeClient(transport)

        print 'Configuration applied'
Exemple #4
0
def configure(sensor, path):
    conf = os.path.join(path, 'conf.yaml')
    if os.path.exists(conf):
        # Reading yaml file
        yf = open(conf, 'r')
        content = yaml.load(yf)
        yf.close()
        
        config = ttypes.SensorConfiguration()
        if 'interval' in content:
            config.interval = int(content['interval'])

        if 'sensorType' in content:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES[content['sensorType']]
        else:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES['METRIC']
            
        parameters = []
        if 'params' in content:
            for key in content['params'].keys():
                param = ttypes.Parameter()
                param.key = key
                param.value = str(content['params'][key])
                parameters.append(param)
        config.parameters = parameters
        
        # Connect with management interface
        transport, client = connect.openClient()
        
        # Update configuration
        client.setSensorConfiguration(sensor, config)
        
        # Close transport
        connect.closeClient(transport)
        
        print 'Configuration applied'
Exemple #5
0
def configure(sensor, path):
    conf = os.path.join(path, "conf.yaml")
    if os.path.exists(conf):
        # Reading yaml file
        yf = open(conf, "r")
        content = yaml.load(yf)
        yf.close()

        config = ttypes.SensorConfiguration()
        if "interval" in content:
            config.interval = int(content["interval"])

        if "sensorType" in content:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES[content["sensorType"]]
        else:
            config.sensorType = ttypes.SensorType._NAMES_TO_VALUES["METRIC"]

        parameters = []
        if "params" in content:
            for key in content["params"].keys():
                param = ttypes.Parameter()
                param.key = key
                param.value = str(content["params"][key])
                parameters.append(param)
        config.parameters = parameters

        # Connect with management interface
        transport, client = connect.openClient()

        # Update configuration
        client.updateSensorConfiguration(sensor, config, [])

        # Close transport
        connect.closeClient(transport)

        print "Configuration applied"