Skip to content

Commit

Permalink
Updating requirements.txt and conda-reqs-pip.txt because of azure pkg…
Browse files Browse the repository at this point in the history
… versions (#77)

* Updating requirements.txt and conda-reqs-pip.txt because of azure-core-cli and azure-mgmt-resource version conflict

Correcting some typos in azure_data.py

* Conflicting versions with conda reqs

* Duplicate and mismatching entry in conda reqs file.

Bug in wsconfig.py if found config.json is not an AzureSentinel config.
  • Loading branch information
ianhelle committed Jul 1, 2020
1 parent 7ea49cb commit 6712d18
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
3 changes: 1 addition & 2 deletions conda/conda-reqs-pip.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
azure-cli-core==2.5.0
azure-cli-core>=2.5.0
azure-core>=1.2.2
azure-identity>=1.3.0
azure-keyvault-secrets>=4.0.0
azure-mgmt-compute>=4.6.2
azure-mgmt-keyvault>=2.0.0
azure-mgmt-monitor>=0.5.2
azure-mgmt-resource>=2.2.0,<=9.0.0
azure-mgmt-subscription>=0.2.0
geoip2>=2.9.0
ipwhois>=1.1.0
Expand Down
2 changes: 1 addition & 1 deletion conda/conda-reqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ adal>=1.2.2
attrs>=18.2.0
azure-common>=1.1.18
azure-mgmt-network>=2.7.0
azure-mgmt-resource>=2.2.0,<=9.0.0
azure-mgmt-resource>=2.2.0
beautifulsoup4>=4.6.3
bokeh>=1.4.0
cryptography>=2.8
Expand Down
32 changes: 22 additions & 10 deletions msticpy/common/wsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,9 @@ def __init__(self, config_file: Optional[str] = None, workspace: str = None):
if Path("./config.json").exists():
config_file = "./config.json"
else:
searched_configs = list(Path("..").glob("**/config.json"))
if not searched_configs:
raise MsticpyUserConfigError(
*_NO_CONFIG_ERR, title="Workspace configuration missing."
)

config_file = str(searched_configs[0])
warnings.warn(
"\n".join(_NO_CONFIG_WARN).format(config_file=config_file)
)
config_file = self._search_for_file("**/config.json")
self._config_file = config_file
#
config = self._read_config_values(config_file)
if config:
self._config.update(config)
Expand Down Expand Up @@ -219,3 +211,23 @@ def _read_pkg_config_values(self, workspace_name: str = None):
self.PKG_CONF_TENANT_KEY
)
return {}

def _search_for_file(self, pattern: str) -> str:
config_file = None
searched_configs = list(Path("..").glob(pattern))
if not searched_configs:
raise MsticpyUserConfigError(
*_NO_CONFIG_ERR, title="Workspace configuration missing."
)
for found_file in searched_configs:
test_content = self._read_config_values(str(found_file))
if "workspace_id" in test_content:
config_file = found_file
break
if config_file is None:
raise MsticpyUserConfigError(
*_NO_CONFIG_ERR, title="Workspace configuration missing."
)
# Warn that we're using a "found" file
warnings.warn("\n".join(_NO_CONFIG_WARN).format(config_file=config_file))
return str(config_file)
16 changes: 8 additions & 8 deletions msticpy/data/azure_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_subscriptions(self) -> pd.DataFrame:
"""Get details of all subscriptions within the tenant."""
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -182,7 +182,7 @@ def get_subscription_info(self, sub_id: str) -> dict:
"""
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -224,7 +224,7 @@ def get_resources(
# Check if connection and client required are already present
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -318,7 +318,7 @@ def get_resource_details(
# Check if connection and client required are already present
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -397,7 +397,7 @@ def _get_api(
# Check if connection and client required are already present
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -473,7 +473,7 @@ def get_network_details(
# Check if connection and client required are already present
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -574,7 +574,7 @@ def get_metrics(
# Check if connection and client required are already present
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down Expand Up @@ -631,7 +631,7 @@ def _get_compute_state(
"""
if self.connected is False:
raise MsticpyNotConnectedError(
"You need to connect to service before using this function.",
"You need to connect to the service before using this function.",
help_uri=MsticpyAzureConfigError.DEF_HELP_URI,
title="Please call connect() before continuing.",
)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
adal>=1.2.2
attrs>=18.2.0
azure-common>=1.1.18
azure-cli-core==2.5.0
azure-cli-core>=2.5.0
azure-core>=1.2.2
azure-identity>=1.3.0
azure-keyvault-secrets>=4.0.0
azure-mgmt-compute>=4.6.2
azure-mgmt-keyvault>=2.0.0
azure-mgmt-monitor>=0.5.2
azure-mgmt-network>=2.7.0
azure-mgmt-resource>=2.2.0,<=9.0.0
azure-mgmt-resource>=2.2.0
azure-mgmt-subscription>=0.2.0
beautifulsoup4>=4.6.3
bokeh>=1.4.0
Expand Down

0 comments on commit 6712d18

Please sign in to comment.