def tearDown(self): """ Clean up all parameters used in test cases :return: None """ self.edge_system = Dell5KEdgeSystem("TestEdgeSystem") self.aws = None
def run(self, registry): from liota.entities.edge_systems.dell5k_edge_system import Dell5KEdgeSystem # getting values from conf file config_path = registry.get("package_conf") config = read_user_config(config_path + '/sampleProp.conf') # Initialize edgesystem edge_system = Dell5KEdgeSystem(config['EdgeSystemName']) registry.register("edge_system", edge_system)
def setUp(self): """ Setup all required parameters required during the tests :return: None """ # EdgeSystem name self.edge_system = Dell5KEdgeSystem("TestEdgeSystem") # Mocking the DataCenterComponent init method with mock.patch("liota.dccs.aws_iot.DataCenterComponent.__init__" ) as mocked_dcc: self.aws = AWSIoT("Mocked DCC", enclose_metadata=True)
def setUp(self): """ Method to initialise the RabbitMQ parameters. :return: None """ # EdgeSystem name self.edge_system = Dell5KEdgeSystem("TestEdgeSystem") # Mocking the DataCenterComponent init method with mock.patch("liota.dccs.rabbitmq.DataCenterComponent.__init__" ) as mocked_dcc: self.rabbitmq_client = RabbitMQ("Mocked connection object", enclose_metadata=False)
def setUp(self): """ Setup all required parameters for AmqpDccComms tests :return: None """ # ConfigParser to parse init file self.config = ConfigParser() self.uuid_file = read_liota_config('UUID_PATH', 'uuid_path') # Broker details self.url = "Broker-IP" self.port = "Broker-Port" self.amqp_username = "******" self.amqp_password = "******" self.enable_authentication = True self.transport = "tcp" self.connection_disconnect_timeout_sec = 2 # EdgeSystem name self.edge_system = Dell5KEdgeSystem("TestGateway") # TLS configurations self.root_ca_cert = "/etc/liota/amqp/conf/ca.crt" self.client_cert_file = "/etc/liota/amqp/conf/client.crt" self.client_key_file = "/etc/liota/amqp/conf/client.key" self.cert_required = "CERT_REQUIRED" self.tls_version = "PROTOCOL_TLSv1" self.cipher = None # Encapsulate the authentication details self.identity = Identity(self.root_ca_cert, self.amqp_username, self.amqp_password, self.client_cert_file, self.client_key_file) # Encapsulate TLS parameters self.tls_conf = TLSConf(self.cert_required, self.tls_version, self.cipher) self.send_message = "test-message" # Creating messaging attributes self.amqp_msg_attr = AmqpPublishMessagingAttributes( exchange_name="test_exchange", routing_key=["test"]) with mock.patch.object(Amqp, '_init_or_re_init') as mocked_init_or_re_init, \ mock.patch.object(Amqp, "declare_publish_exchange") as mocked_declare_publish_exchange: # Instantiate client for DCC communication self.client = AmqpDccComms(edge_system_name=self.edge_system.name, url=self.url, port=self.port)
def run(self, registry): """ The execution function of a liota package. Registers Dell5KEdgeSystem as "edge_system" in package manager's resource registry. :param registry: the instance of ResourceRegistryPerPackage of the package :return: """ from liota.entities.edge_systems.dell5k_edge_system import Dell5KEdgeSystem # getting values from conf file config_path = registry.get("package_conf") config = read_user_config(config_path + '/sampleProp.conf') # Initialize edgesystem edge_system = Dell5KEdgeSystem(config['EdgeSystemName']) registry.register("edge_system", edge_system)
def __init__(self, name=None): from liota.entities.edge_systems.dell5k_edge_system import Dell5KEdgeSystem Thread.__init__(self, name=name) # cmd related obj self.cmd_messenger_thread = None self.cmd_messenger_pipe = None # simulator related obj self.simulator_lock = None # simulator related configuration self.endpoint_list = { } # simulator list: (comm type, ip:port or folder) self.type_dcc_map = { } # Device Type to DCC mapping: (device type, dcc list) self.type_dcc_pkg_map = { } # Device Type to DCC-Package-Name mapping: (device type, dcc-pkg-name list) self.type_key_map = { } # Device Type to Unique Key mapping: (device type, unique key) self.type_tuple_key_dcc_pkg = { } # Device Type to Tuple of (unique key, dcc, dcc_pkg) self._config = {} #key: cfg type, value: cfg list/info self._get_config_from_file( ) # extract configuration from liota.conf first self._executable_check( ) # check based on configuration, simulator thread is executable or not self._save_config() # create an edge system instance config_path = self._config['package_path'] config = {} execfile(config_path + '/sampleProp.conf', config) self.edge_system_object = Dell5KEdgeSystem(config['EdgeSystemName']) # Initialization of simulator messenger queue and lock global cmd_message_queue cmd_message_queue = Queue() self.simulator_lock = Lock() self._simulators = {} # key: beacon type, value: thread ref self.flag_alive = True self.start()
# c) Use custom publish and subscribe topics for Metrics. # - In this case, MQTT message's payload need not be self-descriptive. Subscribers can subscribe to # appropriate topics and process accordingly. # # d) Use combination of (a) and (c) or (b) and (c). # # # AWSIoT DCC has enclose_metadata option. It can be used to enclose EdgeSystem, Device and Metric names # along with the sensor data payload of a Metric. # # This example showcases publishing Metrics using (a) and enclose_metadata # ----------------------------------------------------------------------------------------------------------------- if __name__ == '__main__': # Creating EdgeSystem edge_system = Dell5KEdgeSystem(config['EdgeSystemName']) # Encapsulates Identity identity = Identity(root_ca_cert=config['broker_root_ca_cert'], username=None, password=None, 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']) # Encapsulate QoS related parameters qos_details = QoSDetails(config['in_flight'], config['queue_size'], config['retry']) # Connecting to AWSIoT # AWSIoT broker doesn't support session persistence. So, always use "clean_session=True"