From f4bacc0d210bf7a3621aedb1acfc87b404e4fe93 Mon Sep 17 00:00:00 2001 From: Komal Thareja Date: Wed, 23 Oct 2024 17:47:46 -0400 Subject: [PATCH] update dependencies and display project name as part of show config --- CHANGELOG.md | 1 + fabrictestbed_extensions/fablib/config/config.py | 9 +++++++++ fabrictestbed_extensions/fablib/constants.py | 1 + fabrictestbed_extensions/fablib/fablib.py | 3 +++ pyproject.toml | 2 +- tests/unit/test_basic.py | 4 +--- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b2a4cfc..51dce481 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Node objects returned from slice.get_node(name) are not the same as the node objects returned from slice.get_nodes() (Issue [#380](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/380)) - Multiple calls to fablib.get_slice(name) in the same interpreter yield different objects (Issue [#379](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/379)) - FablibManager.get_slices doesn't return unsubmitted slices created by new_slice() (Issue [#294](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/294)) +- Display Project Name in show_config() (Issue [#384](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/384)) ## [1.7.3] - 08/05/2024 diff --git a/fabrictestbed_extensions/fablib/config/config.py b/fabrictestbed_extensions/fablib/config/config.py index 277eacf6..6ab43e6e 100644 --- a/fabrictestbed_extensions/fablib/config/config.py +++ b/fabrictestbed_extensions/fablib/config/config.py @@ -132,6 +132,7 @@ class Config: Constants.AM_HOST: "Artifact Manager", Constants.TOKEN_LOCATION: "Token File", Constants.PROJECT_ID: "Project ID", + Constants.PROJECT_NAME: "Project Name", Constants.BASTION_USERNAME: "Bastion Username", Constants.BASTION_KEY_LOCATION: "Bastion Private Key File", Constants.BASTION_HOST: "Bastion Host", @@ -568,6 +569,14 @@ def set_project_id(self, project_id: str): """ self.runtime_config[Constants.PROJECT_ID] = project_id + def get_project_name(self): + """ + Get the Project Name: + :return: Project Name + :rtype: String + """ + return self.runtime_config.get(Constants.PROJECT_NAME) + def set_log_level(self, log_level: str = "INFO"): """ Sets the current log level for logging diff --git a/fabrictestbed_extensions/fablib/constants.py b/fabrictestbed_extensions/fablib/constants.py index 8381626e..6f5e9649 100644 --- a/fabrictestbed_extensions/fablib/constants.py +++ b/fabrictestbed_extensions/fablib/constants.py @@ -111,6 +111,7 @@ class Constants: AM_HOST = "am_host" TOKEN_LOCATION = "token_location" PROJECT_ID = "project_id" + PROJECT_NAME = "project_name" BASTION_HOST = "bastion_host" BASTION_USERNAME = "bastion_username" BASTION_KEY_LOCATION = "bastion_key_location" diff --git a/fabrictestbed_extensions/fablib/fablib.py b/fabrictestbed_extensions/fablib/fablib.py index f0fbaab1..9c1b0017 100644 --- a/fabrictestbed_extensions/fablib/fablib.py +++ b/fabrictestbed_extensions/fablib/fablib.py @@ -1160,6 +1160,9 @@ def __build_manager(self) -> FabricManager: logging.debug("Fabric manager initialized!") # Update Project ID to be same as in Slice Manager self.set_project_id(project_id=self.manager.project_id) + self.runtime_config[Constants.PROJECT_NAME] = ( + self.manager.get_project_name() + ) self.determine_bastion_username() except Exception as e: logging.error(e, exc_info=True) diff --git a/pyproject.toml b/pyproject.toml index f12852f4..5a9c4eb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "ipyleaflet", "ipycytoscape", "tabulate", - "fabrictestbed==1.7.8", + "fabrictestbed==1.7.9", "paramiko", "jinja2>=3.0.0", "pandas", diff --git a/tests/unit/test_basic.py b/tests/unit/test_basic.py index 3b1a76f0..cfdfc1f8 100644 --- a/tests/unit/test_basic.py +++ b/tests/unit/test_basic.py @@ -62,9 +62,7 @@ def test_fablib_manager_test_only_orchestrator_host(self): def test_fablib_manager_test_only_project_id(self): os.environ[Constants.FABRIC_PROJECT_ID] = "dummy" os.environ[Constants.FABRIC_TOKEN_LOCATION] = self.DUMMY_TOKEN_LOCATION - self.assertRaises( - TokenManagerException, FablibManager, fabric_rc=self.rcfile.name - ) + self.assertRaises(Exception, FablibManager, fabric_rc=self.rcfile.name) def test_fablib_manager_test_only_token_location(self): os.environ[Constants.FABRIC_TOKEN_LOCATION] = "dummy"