Beispiel #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'])
Beispiel #2
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over MQTT Protocol to acquire "registered edge system", i.e. iotcc_edge_system.
    """

    def run(self, registry):
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

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

        #  Encapsulates Identity
        identity = Identity(root_ca_cert=config['broker_root_ca_cert'], username=config['broker_username'],
                            password=config['broker_password'],
                            cert_file=config['edge_system_cert_file'], key_file=config['edge_system_key_file'])

        # Encapsulate TLS parameters
        tls_conf = TLSConf(config['cert_required'], config['tls_version'], config['cipher'])

        # Initialize DCC object with MQTT transport
        self.iotcc = IotControlCenter(MqttDccComms(edge_system_name=edge_system.name,
                                              url=config['BrokerIP'], port=config['BrokerPort'], identity=identity,
                                              tls_conf=tls_conf,
                                              enable_authentication=True))

        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_mqtt", self.iotcc)
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(self.iotcc_edge_system, config['SystemPropList'])

    def clean_up(self):
        # Get values from configuration file
        config = read_user_config(self.config_path + '/sampleProp.conf')

        #Unregister edge system
        if config['ShouldUnregisterOnUnload'] == "True":
            self.iotcc.unregister(self.iotcc_edge_system)
        self.iotcc.comms.client.disconnect()
Beispiel #3
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over WebSocket to acquire "registered edge system", i.e. iotcc_edge_system.
    """
    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'])

    def clean_up(self):
        # Get values from configuration file
        config = read_user_config(self.config_path + '/sampleProp.conf')

        # Unregister edge system
        if config['ShouldUnregisterOnUnload'] == "True":
            self.iotcc.unregister(self.iotcc_edge_system)
        self.iotcc.comms.client.close()
Beispiel #4
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over MQTT Protocol to acquire "registered edge system", i.e. iotcc_edge_system.
    """
    def run(self, registry):
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.dccs.dcc import RegistrationFailure

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

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

        #  Encapsulates Identity
        identity = Identity(root_ca_cert=None,
                            username=config['broker_username'],
                            password=config['broker_password'],
                            cert_file=None,
                            key_file=None)

        # Initialize DCC object with MQTT transport
        self.iotcc = IotControlCenter(
            config['broker_username'], config['broker_password'],
            MqttDccComms(edge_system_name=edge_system.name,
                         url=config['BrokerIP'],
                         port=config['BrokerPort'],
                         identity=identity,
                         enable_authentication=True,
                         clean_session=True))

        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_mqtt", self.iotcc)
            registry.register("iotcc_edge_system_mqtt", iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(iotcc_edge_system, config['SystemPropList'])

    def clean_up(self):
        self.iotcc.comms.client.disconnect()
Beispiel #5
0
    def run(self, registry):
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

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

        #  Encapsulates Identity
        identity = Identity(root_ca_cert=config['broker_root_ca_cert'],
                            username=config['broker_username'],
                            password=config['broker_password'],
                            cert_file=config['edge_system_cert_file'],
                            key_file=config['edge_system_key_file'])

        # Encapsulate TLS parameters
        tls_conf = TLSConf(config['cert_required'], config['tls_version'],
                           config['cipher'])

        # Initialize DCC object with MQTT transport
        self.iotcc = IotControlCenter(
            config['broker_username'], config['broker_password'],
            MqttDccComms(edge_system_name=edge_system.name,
                         url=config['BrokerIP'],
                         port=config['BrokerPort'],
                         identity=identity,
                         tls_conf=tls_conf,
                         enable_authentication=True))

        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_mqtt", self.iotcc)
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(self.iotcc_edge_system,
                                  config['SystemPropList'])
Beispiel #6
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over WebSocket to acquire "registered edge system", i.e. iotcc_edge_system.
    """

    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'])

    def clean_up(self):
        # Get values from configuration file
        config = read_user_config(self.config_path + '/sampleProp.conf')

        # Unregister edge system
        if config['ShouldUnregisterOnUnload'] == "True":
            self.iotcc.unregister(self.iotcc_edge_system)
        self.iotcc.comms.client.close()
Beispiel #7
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)

            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'])
Beispiel #8
0
    def run(self, registry):
        import copy
        import time
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"), username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"), key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED", tls_version="PROTOCOL_TLSv1_2", cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(pub_topic="liota/"+registry.get("broker_username")+"/request",sub_topic="liota/"+registry.get("broker_username")+"/response")
        self.iotcc = IotControlCenter(MqttDccComms(edge_system_name=edge_system.name,
                                              url=registry.get("broker_ip"), port=registry.get("broker_port"), identity=identity,
                                              tls_conf=tls_conf,client_id=registry.get("broker_username"),
                                              enable_authentication=True, mqtt_msg_attr=mqtt_msg_attr))

        try:
            # Register edge system (gateway)
            self.iotcc_edge_system = self.iotcc.register(edge_system)
            # System Properties has to be set only for the registered edge system before it is stored in the package
            # manager registry, all the devices will internally inherit the the system properties from the
            # registered edge system
            self.iotcc.set_system_properties(self.iotcc_edge_system, registry.get("system_properties"))
            # Set the properties for edge system as key:value pair, you can also set the location
            # by passing the latitude and longitude as a property in the user package
            # If the set_properties or register call fails due to DCC_Comms Publish exception
            # the optional retry mechanism can be implemented in the following way
            attempts = 0
            while attempts < 3:
                try:
                    # Register edge system (gateway)
                    self.iotcc.set_properties(self.iotcc_edge_system, {"key1": "value1", "key2": "value2"})
                    break
                except Exception:
                    attempts += 1
                    # The sleep time before re-trying depends on the infrastructure requirement of broker to restart
                    # It can be modified or removed as per the infrastructure requirement
                    time.sleep(5)
            registry.register("iotcc_mqtt", self.iotcc)
            # Store the registered edge system object in liota package manager registry after the
            # system properties are set for it
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
Beispiel #9
0
    def run(self, registry):
        """
        The execution function of a liota package.

        Establishes connection with IoTControlCenter DCC using MqttDccComms

        :param registry: the instance of ResourceRegistryPerPackage of the package
        :return:
        """
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

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

        #  Encapsulates Identity
        identity = Identity(root_ca_cert=config['broker_root_ca_cert'], username=config['broker_username'],
                            password=config['broker_password'],
                            cert_file=config['edge_system_cert_file'], key_file=config['edge_system_key_file'])

        # Encapsulate TLS parameters
        tls_conf = TLSConf(config['cert_required'], config['tls_version'], config['cipher'])

        # Initialize DCC object with MQTT transport
        self.iotcc = IotControlCenter(MqttDccComms(edge_system_name=edge_system.name,
                                              url=config['BrokerIP'], port=config['BrokerPort'], identity=identity,
                                              tls_conf=tls_conf,
                                              enable_authentication=True))

        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_mqtt", self.iotcc)
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
        self.iotcc.set_properties(self.iotcc_edge_system, config['SystemPropList'])
Beispiel #10
0
class PackageClass(LiotaPackage):
    """
    This package creates a IoTControlCenter DCC object and registers edge system on
    IoTCC to acquire "registered edge system", i.e. iotcc_edge_system.
    """
    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)

            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'])

    def clean_up(self):
        self.iotcc.comms.wss.close()
Beispiel #11
0
class PackageClass(LiotaPackage):
    """
    This package creates a IoTControlCenter DCC object and registers edge system on
    IoTCC to acquire "registered edge system", i.e. iotcc_edge_system.
    """

    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)

            registry.register("iotcc", self.iotcc)
            registry.register("iotcc_edge_system", iotcc_edge_system)
        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"

    def clean_up(self):
        self.iotcc.comms.wss.close()
    #  Creating EdgeSystem
    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])
    #  Encapsulates Identity
    identity = Identity(root_ca_cert=config['broker_root_ca_cert'],
                        username=config['broker_username'],
                        password=config['broker_password'],
                        cert_file=config['edge_system_cert_file'],
                        key_file=config['edge_system_key_file'])
    # Encapsulate TLS parameters
    tls_conf = TLSConf(config['cert_required'], config['tls_version'],
                       config['cipher'])

    iotcc = IotControlCenter(
        MqttDccComms(edge_system_name=edge_system.name,
                     url=config['BrokerIP'],
                     port=config['BrokerPort'],
                     identity=identity,
                     tls_conf=tls_conf,
                     enable_authentication=True))

    try:

        # 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
    #  Creating EdgeSystem
    edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

    # Connect with MQTT broker using DeviceComms and subscribe to topics
    # Get kitchen and living room temperature values using MQTT channel
    mqtt_subscribe()

    # Create DCC object IoTCC using websocket transport
    # with UID and PASS
    ws_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=ws_identity)
    )

    try:

        # Register Edge System with IoT control center
        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 kitchen device object and register it on IoTCC
        # Add two device names in the configurations as DeviceName1 and DeviceName2
        kitchen_temperature_device = SimulatedDevice(name=config['DeviceName1'])
        reg_kitchen_temperature_device = iotcc.register(kitchen_temperature_device)
Beispiel #14
0
    def run(self, registry):
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"),
                            username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"),
                            key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED",
                           tls_version="PROTOCOL_TLSv1_2",
                           cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(
            pub_topic="liota/" + registry.get("broker_username") + "/request",
            sub_topic="liota/" + registry.get("broker_username") + "/response")
        self.iotcc = IotControlCenter(
            MqttDccComms(edge_system_name=edge_system.name,
                         url=registry.get("broker_ip"),
                         port=registry.get("broker_port"),
                         identity=identity,
                         tls_conf=tls_conf,
                         client_id=registry.get("broker_username"),
                         enable_authentication=True,
                         mqtt_msg_attr=mqtt_msg_attr))

        try:
            # Register edge system (gateway)
            self.iotcc_edge_system = self.iotcc.register(edge_system)
            # System Properties has to be set only for the registered edge system before it is stored in the package
            # manager registry, all the devices will internally inherit the the system properties from the
            # registered edge system
            self.iotcc.set_system_properties(self.iotcc_edge_system,
                                             registry.get("system_properties"))
            # Set the properties for edge system as key:value pair, you can also set the location
            # by passing the latitude and longitude as a property in the user package
            self.iotcc.set_properties(self.iotcc_edge_system, {
                "key1": "value1",
                "key2": "value2"
            })
            registry.register("iotcc_mqtt", self.iotcc)
            # Store the registered edge system object in liota package manager registry after the
            # system properties are set for it
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
Beispiel #15
0
                                clean_session=True,
                                port=config['BrokerPort'],
                                keep_alive=config['keep_alive'],
                                enable_authentication=True)

    # Subscribe to channels : "temperature/kitchen" and "temperature/living-room" with preferred QoS level 0, 1 or 2
    # Provide callback function as a parameter for corresponding channel
    mqtt_conn.subscribe(config['MqttChannel1'], 1, callback_kitchen_temp)
    mqtt_conn.subscribe(config['MqttChannel2'], 1, callback_living_room_temp)


if __name__ == "__main__":

    # Create DCC object IoTCC using websocket transport
    # with UID and PASS
    iotcc = IotControlCenter(config['IotCCUID'], config['IotCCPassword'],
                             WebSocketDccComms(url=config['WebSocketUrl']))

    try:

        # Create an Edge System Dk300
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # Get kitchen and living room temperature values using MQTT channel
        mqtt_subscribe(edge_system)

        # Register Edge System with IoT control center
        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'])
if __name__ == '__main__':

    # create a data center object, IoTCC in this case, using MQTT 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.

    #  Creating EdgeSystem
    edge_system = Dell5KEdgeSystem(config['EdgeSystemName'])
    #  Encapsulates Identity
    identity = Identity(root_ca_cert=config['broker_root_ca_cert'], username=config['broker_username'], password=config['broker_password'],
                        cert_file=config['edge_system_cert_file'], key_file=config['edge_system_key_file'])
    # Encapsulate TLS parameters
    tls_conf = TLSConf(config['cert_required'], config['tls_version'], config['cipher'])

    iotcc = IotControlCenter(MqttDccComms(edge_system_name=edge_system.name,
                                          url=config['BrokerIP'], port=config['BrokerPort'], identity=identity,
                                          tls_conf=tls_conf,
                                          enable_authentication=True))

    try:

        # 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
        # arguments:
        # local object referring to the Resource in IoTCC on which the metric should be associated
Beispiel #17
0
    mem_free_percent = ((total_mem-free_mem)/total_mem)*100
    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
    return rpm_model_queue.get(block=True)

def action_actuator(value):
    print value



# ---------------------------------------------------------------------------------------
# In this example, we demonstrate how metrics collected from a SensorTag device over BLE
# can be directed to IoTCC data center component 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
    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'])

        # Operational metrics of EdgeSystem
Beispiel #19
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over MQTT Protocol to acquire "registered edge system", i.e. iotcc_edge_system.
    """
    def run(self, registry):
        import copy
        import time
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"),
                            username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"),
                            key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED",
                           tls_version="PROTOCOL_TLSv1_2",
                           cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(
            pub_topic="liota/" + registry.get("broker_username") + "/request",
            sub_topic="liota/" + registry.get("broker_username") + "/response")
        self.iotcc = IotControlCenter(
            MqttDccComms(edge_system_name=edge_system.name,
                         url=registry.get("broker_ip"),
                         port=registry.get("broker_port"),
                         identity=identity,
                         tls_conf=tls_conf,
                         client_id=registry.get("broker_username"),
                         enable_authentication=True,
                         mqtt_msg_attr=mqtt_msg_attr))

        try:
            # Register edge system (gateway)
            self.iotcc_edge_system = self.iotcc.register(edge_system)
            # System Properties has to be set only for the registered edge system before it is stored in the package
            # manager registry, all the devices will internally inherit the the system properties from the
            # registered edge system
            self.iotcc.set_system_properties(self.iotcc_edge_system,
                                             registry.get("system_properties"))
            # Set the properties for edge system as key:value pair, you can also set the location
            # by passing the latitude and longitude as a property in the user package
            # If the set_properties or register call fails due to DCC_Comms Publish exception
            # the optional retry mechanism can be implemented in the following way
            attempts = 0
            while attempts < 3:
                try:
                    # Register edge system (gateway)
                    self.iotcc.set_properties(self.iotcc_edge_system, {
                        "key1": "value1",
                        "key2": "value2"
                    })
                    break
                except Exception:
                    attempts += 1
                    # The sleep time before re-trying depends on the infrastructure requirement of broker to restart
                    # It can be modified or removed as per the infrastructure requirement
                    time.sleep(5)
            registry.register("iotcc_mqtt", self.iotcc)
            # Store the registered edge system object in liota package manager registry after the
            # system properties are set for it
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"

    def clean_up(self):
        # Unregister the edge system on package unload
        # Kindly include the edge system un-register call on package unload
        self.iotcc.unregister(self.iotcc_edge_system)
        self.iotcc.comms.client.disconnect()
        thermistor_model.get_c3(),
        get_rx(thermistor_model.get_u(), thermistor_model.get_r0(),
               thermistor_model.get_ux())).to(ureg.degC)
    return temper.magnitude


# ---------------------------------------------------------------------------
# In this example, we demonstrate how simulated data can be directed to IoTCC
# VMware's data center component using Liota.

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 neccessary 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 Edge System object encapsulating the particulars of a gateway/board
        # argument is the name of this Edge System
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # resister the Edge 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'])
Beispiel #21
0
                       10 * ureg.kg / ureg.m**3).to(ureg.newton),
        speed).to(ureg.watt)
    power = power_acceleration + power_gravity + power_resistance
    return power.to(ureg.watt).magnitude


# ---------------------------------------------------------------------------
# In this example, we demonstrate how simulated data can be directed to IoTCC
# VMware's data center component using Liota.

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 neccessary 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 Edge System object encapsulating the particulars of a gateway/board
        # argument is the name of this Edge System
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # resister the Edge 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'])
# ---------------------------------------------------------------------------
# In this example, we demonstrate how simulated data can be directed to IoTCC
# VMware's data center component using Liota.

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 neccessary 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 Edge System object encapsulating the particulars of a gateway/board
        # argument is the name of this Edge System
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # resister the Edge 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'])
Beispiel #23
0
# ---------------------------------------------------------------------------
# In this example, we demonstrate how simulated data can be directed to IoTCC
# VMware's data center component using Liota.

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 neccessary 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 Edge System object encapsulating the particulars of a gateway/board
        # argument is the name of this Edge System
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # resister the Edge 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'])
Beispiel #24
0
    def run(self, registry):
        """
        The execution function of a liota package.

        Establishes connection with IoTControlCenter DCC using MqttDccComms

        :param registry: the instance of ResourceRegistryPerPackage of the package
        :return:
        """
        import copy
        import time
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.dccs.dcc import RegistrationFailure
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"), username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"),
                            key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED", tls_version="PROTOCOL_TLSv1_2", cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(pub_topic="liota/" + registry.get("broker_username") + "/request",
                                                sub_topic="liota/" + registry.get("broker_username") + "/response")
        self.iotcc = IotControlCenter(MqttDccComms(edge_system_name=edge_system.name,
                                                   url=registry.get("broker_ip"), port=registry.get("broker_port"),
                                                   identity=identity,
                                                   tls_conf=tls_conf, client_id=registry.get("broker_username"),
                                                   enable_authentication=True, mqtt_msg_attr=mqtt_msg_attr))

        try:
            # Register edge system (gateway)
            self.iotcc_edge_system = self.iotcc.register(edge_system)
            # Set the properties for edge system as key:value pair, you can also set the location
            # by passing the latitude and longitude as a property in the user package
            # If the set_properties or register call fails due to DCC_Comms Publish exception
            # the optional retry mechanism can be implemented in the following way
            attempts = 0
            max_retry_attempts = 3
            while attempts < max_retry_attempts:
                try:
                    # Register edge system (gateway)
                    self.iotcc.set_properties(self.iotcc_edge_system, {"key1": "value1", "key2": "value2"})
                    break
                except Exception:
                    # In the third attempt if get exception raise it
                    if attempts == max_retry_attempts:
                        raise
                    attempts += 1
                    # The sleep time before re-trying depends on the infrastructure requirement of broker to restart
                    # It can be modified or removed as per the infrastructure requirement
                    time.sleep(5)
            registry.register("iotcc_mqtt", self.iotcc)
            # Store the registered edge system object in liota package manager registry after the
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

        except RegistrationFailure:
            print "EdgeSystem registration to IOTCC failed"
Beispiel #25
0
    def run(self, registry):
        """
        The execution function of a liota package.
        Establishes connection with IoTControlCenter DCC using MqttDccComms
        :param registry: the instance of ResourceRegistryPerPackage of the package
        :return:
        """
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"), username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"),
                            key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED", tls_version="PROTOCOL_TLSv1_2", cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(pub_topic="liota/" + registry.get("broker_username") + "/request",
                                                sub_topic="liota/" + registry.get("broker_username") + "/response")

        # Attempts for establishing MQTT Connection
        conn_attempts = 0

        try:
            # Trying to establish MQTT Connection with retry attempts in case of exception
            while conn_attempts <= retry_attempts:
                try:
                    self.iotcc = IotControlCenter(
                        MqttDccComms(edge_system_name=edge_system.name, url=registry.get("broker_ip"),
                                     port=registry.get("broker_port"), identity=identity, tls_conf=tls_conf,
                                     client_id=registry.get("broker_username"), enable_authentication=True,
                                     mqtt_msg_attr=mqtt_msg_attr))
                    break
                except Exception as e:
                    if conn_attempts == retry_attempts:
                        raise
                    conn_attempts += 1
                    log.error('MQTT Connection failed - {0}'.format(str(e)))
                    log.info('Trying MQTT Connection: Attempt - {0}'.format(str(conn_attempts)))
                    time.sleep(mqtt_connection_delay_retries)

            # Attempts for Edge System Registration
            reg_attempts = 0
            # Edge System Registration with retry attempts in case of exception
            while reg_attempts <= retry_attempts:
                try:
                    self.iotcc_edge_system = self.iotcc.register(edge_system)
                    break
                except Exception as e:
                    if reg_attempts == retry_attempts:
                        raise
                    reg_attempts += 1
                    log.error('Exception while registering Edge System- {0}'.format(str(e)))
                    log.info('Trying Edge System {0} Registration: Attempt - {1}'.format(edge_system.name,
                                                                                         str(reg_attempts)))
                    time.sleep(delay_retries)

            registry.register("iotcc_mqtt", self.iotcc)
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

            # Attempts for setting edge system properties
            prop_attempts = 0
            # Set multiple properties by passing Dictonary object for Edge System with the retry attempts
            # in case of exceptions
            while prop_attempts < retry_attempts:
                try:
                    self.iotcc.set_properties(self.iotcc_edge_system,
                                              {"Country": "USA-G", "State": "California", "City": "Palo Alto",
                                               "Location": "VMware HQ", "Building": "Promontory H Lab",
                                               "Floor": "First Floor"})
                    break
                except Exception as e:
                    prop_attempts += 1
                    log.error(
                        'Exception while setting Property for Edge System {0} - {1}'.format(edge_system.name, str(e)))
                    log.info('Trying setting properties for Edge System {0}: Attempt - {1}'.format(edge_system.name,
                                                                                                   str(prop_attempts)))
                    time.sleep(delay_retries)

        except Exception:
            log.error("EdgeSystem registration to IOTCC failed even after all the retries, starting connection cleanup")
            # Disconnecting MQTT
            self.iotcc.comms.client.disconnect()
            raise
Beispiel #26
0
# 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.
    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'])
Beispiel #27
0
class PackageClass(LiotaPackage):
    """
    This is a sample package which creates a IoTControlCenter DCC object and registers edge system on
    IoTCC over MQTT Protocol to acquire "registered edge system", i.e. iotcc_edge_system.
    """
    def run(self, registry):
        """
        The execution function of a liota package.
        Establishes connection with IoTControlCenter DCC using MqttDccComms
        :param registry: the instance of ResourceRegistryPerPackage of the package
        :return:
        """
        import copy
        from liota.lib.utilities.identity import Identity
        from liota.dccs.iotcc import IotControlCenter
        from liota.dcc_comms.mqtt_dcc_comms import MqttDccComms
        from liota.lib.transports.mqtt import MqttMessagingAttributes
        from liota.lib.utilities.tls_conf import TLSConf

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

        #  Encapsulates Identity
        # Acquire credentials and required certificates from the registry
        identity = Identity(root_ca_cert=registry.get("broker_root_ca_cert"),
                            username=registry.get("broker_username"),
                            password=registry.get("broker_password"),
                            cert_file=registry.get("edge_system_cert_file"),
                            key_file=registry.get("edge_system_key_file"))

        # Encapsulate TLS parameters
        tls_conf = TLSConf(cert_required="CERT_REQUIRED",
                           tls_version="PROTOCOL_TLSv1_2",
                           cipher=None)

        # Initialize DCC object with MQTT transport
        mqtt_msg_attr = MqttMessagingAttributes(
            pub_topic="liota/" + registry.get("broker_username") + "/request",
            sub_topic="liota/" + registry.get("broker_username") + "/response")

        # Attempts for establishing MQTT Connection
        conn_attempts = 0

        try:
            # Trying to establish MQTT Connection with retry attempts in case of exception
            while conn_attempts <= retry_attempts:
                try:
                    self.iotcc = IotControlCenter(
                        MqttDccComms(edge_system_name=edge_system.name,
                                     url=registry.get("broker_ip"),
                                     port=registry.get("broker_port"),
                                     identity=identity,
                                     tls_conf=tls_conf,
                                     client_id=registry.get("broker_username"),
                                     enable_authentication=True,
                                     mqtt_msg_attr=mqtt_msg_attr))
                    break
                except Exception as e:
                    if conn_attempts == retry_attempts:
                        raise
                    conn_attempts += 1
                    log.error('MQTT Connection failed - {0}'.format(str(e)))
                    log.info('Trying MQTT Connection: Attempt - {0}'.format(
                        str(conn_attempts)))
                    time.sleep(mqtt_connection_delay_retries)

            # Attempts for Edge System Registration
            reg_attempts = 0
            # Edge System Registration with retry attempts in case of exception
            while reg_attempts <= retry_attempts:
                try:
                    self.iotcc_edge_system = self.iotcc.register(edge_system)
                    break
                except Exception as e:
                    if reg_attempts == retry_attempts:
                        raise
                    reg_attempts += 1
                    log.error(
                        'Exception while registering Edge System- {0}'.format(
                            str(e)))
                    log.info(
                        'Trying Edge System {0} Registration: Attempt - {1}'.
                        format(edge_system.name, str(reg_attempts)))
                    time.sleep(delay_retries)

            registry.register("iotcc_mqtt", self.iotcc)
            registry.register("iotcc_mqtt_edge_system", self.iotcc_edge_system)

            # Attempts for setting edge system properties
            prop_attempts = 0
            # Set multiple properties by passing Dictonary object for Edge System with the retry attempts
            # in case of exceptions
            while prop_attempts < retry_attempts:
                try:
                    self.iotcc.set_properties(self.iotcc_edge_system,
                                              config['SystemPropList'])
                    break
                except Exception as e:
                    prop_attempts += 1
                    log.error(
                        'Exception while setting Property for Edge System {0} - {1}'
                        .format(edge_system.name, str(e)))
                    log.info(
                        'Trying setting properties for Edge System {0}: Attempt - {1}'
                        .format(edge_system.name, str(prop_attempts)))
                    time.sleep(delay_retries)

        except Exception:
            log.error(
                "EdgeSystem registration to IOTCC failed even after all the retries, starting connection cleanup"
            )
            # Disconnecting MQTT
            self.iotcc.comms.client.disconnect()
            raise

    def clean_up(self):
        # Unregister the edge system
        # On the unload of the package the Edge System will get unregistered and the entire history will be deleted
        # from Pulse IoT Control Center so comment the below logic if the unregsitration of the device is not required
        # to be done on the package unload
        self.iotcc.unregister(self.iotcc_edge_system)
        # Disconnecting MQTT
        self.iotcc.comms.client.disconnect()
        log.info("Cleanup completed successfully")