How to use the iotedgedev.connectionstring.DeviceConnectionString function in iotedgedev

To help you get started, we’ve selected a few iotedgedev examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_invalid_devicehub_connectionstring():
    connectionstring = DeviceConnectionString(invalid_device_connectionstring)
    assert connectionstring.iothub_host.name == "testhub.azure-devices.net"
    assert connectionstring.iothub_host.hub_name == "testhub"
    assert not connectionstring.device_id
    assert connectionstring.shared_access_key == "othergibberish"
github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_empty_device_connectionstring():
    connectionstring = DeviceConnectionString(emptystring)
    assert not connectionstring.data
github Azure / iotedgedev / tests / test_connectionstring.py View on Github external
def test_valid_devicehub_connectionstring():
    connectionstring = DeviceConnectionString(valid_device_connectionstring)
    assert connectionstring.iothub_host.name == "testhub.azure-devices.net"
    assert connectionstring.iothub_host.hub_name == "testhub"
    assert connectionstring.device_id == "testdevice"
    assert connectionstring.shared_access_key == "othergibberish"
github Azure / iotedgedev / tests / test_iotedgedev.py View on Github external
def test_valid_env_device_connectionstring():
    """Test for loading data of env file"""

    env_device_connectionstring = os.getenv("DEVICE_CONNECTION_STRING")
    connectionstring = DeviceConnectionString(env_device_connectionstring)

    assert connectionstring.iothub_host.name
    assert connectionstring.iothub_host.hub_name
    assert connectionstring.shared_access_key
    assert connectionstring.device_id
github Azure / iotedgedev / iotedgedev / iotedgedev.py View on Github external
self.load_dotenv()

            try:
                try:
                    self.IOTHUB_CONNECTION_STRING = self.get_envvar(
                        "IOTHUB_CONNECTION_STRING")
                    self.IOTHUB_CONNECTION_INFO = IoTHubConnectionString(
                        self.IOTHUB_CONNECTION_STRING)
                except:
                    self.output.error("ERROR: Unable to parse IOTHUB_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set.")
                    sys.exit(-1)

                try:
                    self.DEVICE_CONNECTION_STRING = self.get_envvar(
                        "DEVICE_CONNECTION_STRING")
                    self.DEVICE_CONNECTION_INFO = DeviceConnectionString(
                        self.DEVICE_CONNECTION_STRING)
                except:
                    self.output.error("ERROR: Unable to parse DEVICE_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set.")
                    sys.exit(-1)

                
                self.RUNTIME_HOST_NAME = self.get_envvar("RUNTIME_HOST_NAME")
                if self.RUNTIME_HOST_NAME == ".":
                    self.set_envvar("RUNTIME_HOST_NAME", socket.gethostname())

                self.RUNTIME_HOME_DIR = self.get_envvar("RUNTIME_HOME_DIR")
                if self.RUNTIME_HOME_DIR == ".":
                    self.set_envvar("RUNTIME_HOME_DIR", self.get_runtime_home_dir())


                self.RUNTIME_CONFIG_DIR = self.get_envvar("RUNTIME_CONFIG_DIR")
github Azure / iotedgedev / iotedgedev / envvars.py View on Github external
try:
                try:
                    self.IOTHUB_CONNECTION_STRING = self.get_envvar("IOTHUB_CONNECTION_STRING")
                    self.IOTHUB_CONNECTION_INFO = None
                    if self.IOTHUB_CONNECTION_STRING:
                        self.IOTHUB_CONNECTION_INFO = IoTHubConnectionString(self.IOTHUB_CONNECTION_STRING)

                except Exception as ex:
                    raise ValueError("Unable to parse IOTHUB_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set. {0}".format(str(ex)))

                try:
                    self.DEVICE_CONNECTION_STRING = self.get_envvar("DEVICE_CONNECTION_STRING")
                    self.DEVICE_CONNECTION_INFO = None
                    if self.DEVICE_CONNECTION_STRING:
                        self.DEVICE_CONNECTION_INFO = DeviceConnectionString(self.DEVICE_CONNECTION_STRING)

                except Exception as ex:
                    raise ValueError("Unable to parse DEVICE_CONNECTION_STRING Environment Variable. Please ensure that you have the right connection string set. {0}".format(str(ex)))

                self.get_registries()

                self.BYPASS_MODULES = self.get_envvar("BYPASS_MODULES", default="")
                self.CONTAINER_TAG = self.get_envvar("CONTAINER_TAG", default="")
                self.RUNTIME_TAG = self.get_envvar("RUNTIME_TAG", default="1.0")
                self.CONFIG_OUTPUT_DIR = self.get_envvar("CONFIG_OUTPUT_DIR", default=Constants.default_config_folder)
                self.DEPLOYMENT_CONFIG_TEMPLATE_FILE = self.get_envvar("DEPLOYMENT_CONFIG_TEMPLATE_FILE", default=Constants.default_deployment_template_file)
                self.DEPLOYMENT_CONFIG_DEBUG_TEMPLATE_FILE = self.get_envvar("DEPLOYMENT_CONFIG_DEBUG_TEMPLATE_FILE", default=Constants.default_deployment_debug_template_file)
                self.DEFAULT_PLATFORM = self.get_envvar("DEFAULT_PLATFORM", default=Constants.default_platform)
                self.DEPLOYMENT_CONFIG_FILE = Utility.get_deployment_manifest_name(self.DEPLOYMENT_CONFIG_TEMPLATE_FILE, None, self.DEFAULT_PLATFORM)
                self.MODULES_PATH = self.get_envvar("MODULES_PATH", default=Constants.default_modules_folder)
                self.LOGS_PATH = self.get_envvar("LOGS_PATH", default="logs")