Exemple #1
0
    def run(self, registry):
        import copy
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.websocket_dcc_comms import WebSocketDccComms
        from liota.dccs.dcc import RegistrationFailure

        # Acquire resources from registry
        # Creating a copy of edge_system object to keep original object "clean"
        edge_system = copy.copy(registry.get("edge_system"))

        # Get values from configuration file
        config_path = registry.get("package_conf")
        config = {}
        execfile(config_path + '/sampleProp.conf', config)

        # Initialize DCC object with transport
        self.iotcc = IotControlCenter(
            config['IotCCUID'], config['IotCCPassword'],
            WebSocketDccComms(url=config['WebSocketUrl'])
        )

        try:
            # Register edge system (gateway)
            iotcc_edge_system = self.iotcc.register(edge_system)
            """
            Use iotcc & iotcc_edge_system as common identifiers
            in the registry to easily refer the objects in other packages
            """
            registry.register("iotcc", self.iotcc)
            registry.register("iotcc_edge_system", iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(iotcc_edge_system, config['SystemPropList'])
Exemple #2
0
    def run(self, registry):
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.websocket_dcc_comms import WebSocketDccComms
        from liota.dccs.dcc import RegistrationFailure

        # Acquire resources from registry
        # Creating a copy of edge_system object to keep original object "clean"
        edge_system = copy.copy(registry.get("edge_system"))

        # Get values from configuration file
        self.config_path = registry.get("package_conf")
        config = read_user_config(self.config_path + '/sampleProp.conf')

        identity = Identity(root_ca_cert=config['WebsocketCaCertFile'],
                            username=config['IotCCUID'],
                            password=config['IotCCPassword'],
                            cert_file=config['ClientCertFile'],
                            key_file=config['ClientKeyFile'])

        # Initialize DCC object with transport
        self.iotcc = IotControlCenter(
            WebSocketDccComms(url=config['WebSocketUrl'],
                              verify_cert=config['VerifyServerCert'],
                              identity=identity))

        try:
            # Register edge system (gateway)
            self.iotcc_edge_system = self.iotcc.register(edge_system)
            """
            Use iotcc & iotcc_edge_system as common identifiers
            in the registry to easily refer the objects in other packages
            """
            registry.register("iotcc", self.iotcc)
            registry.register("iotcc_edge_system", self.iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(self.iotcc_edge_system,
                                  config['SystemPropList'])
Exemple #3
0
if __name__ == '__main__':

    # create a data center object, IoTCC in this case, using websocket as a transport layer
    # this object encapsulates the formats and protocols necessary for the agent to interact with the dcc
    # UID/PASS login for now.
    identity = Identity(root_ca_cert=config['WebsocketCaCertFile'],
                        username=config['IotCCUID'],
                        password=config['IotCCPassword'],
                        cert_file=config['ClientCertFile'],
                        key_file=config['ClientKeyFile'])

    # Initialize DCC object with transport
    iotcc = IotControlCenter(
        WebSocketDccComms(url=config['WebSocketUrl'],
                          verify_cert=config['VerifyServerCert'],
                          identity=identity))

    try:
        # create a System object encapsulating the particulars of a IoT System
        # argument is the name of this IoT System
        edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

        # resister the IoT System with the IoTCC instance
        # this call creates a representation (a Resource) in IoTCC for this IoT System with the name given
        reg_edge_system = iotcc.register(edge_system)

        # these call set properties on the Resource representing the IoT System
        # properties are a key:value store
        reg_edge_system.set_properties(config['SystemPropList'])
Exemple #4
0
    return round(mem_free_percent, 2)

    
#---------------------------------------------------------------------------
# In this example, we demonstrate how System health and some simulated data
# can be directed to data center component IoTCC using Liota.
# The program illustrates the ease of use Liota brings to IoT application developers.

if __name__ == '__main__':


    # create a data center object, IoTCC in this case, using websocket as a transport layer
    # this object encapsulates the formats and protocols necessary for the agent to interact with the dcc
    # UID/PASS login for now.
    iotcc = IotControlCenter(config['IotCCUID'], config['IotCCPassword'],
                             WebSocketDccComms(url=config['WebSocketUrl']))

    try:
        # create a System object encapsulating the particulars of a IoT System
        # argument is the name of this IoT System
        edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])

        # resister the IoT System with the IoTCC instance
        # this call creates a representation (a Resource) in IoTCC for this IoT System with the name given
        reg_edge_system = iotcc.register(edge_system)

        # these call set properties on the Resource representing the IoT System
        # properties are a key:value store
        reg_edge_system.set_properties(config['SystemPropList'])

        # ---------- Create metrics 'on' the Resource in IoTCC representing the IoT System