Skip to content

Commit

Permalink
Enable OBSClient security provider policy chain
Browse files Browse the repository at this point in the history
1. Enable OBSClient security provider policy chain, it can work
with ENV "OBS_ACCESS_KEY_ID" and "OBS_SECRET_ACCESS_KEY" or
ECS agent to get AK/SK automatically, it's disable by default.
2. Fix cloud.storage.uri return a whole OBS bucket URI for
command "cloudtik workspace info"

Related-with: oap-project#1011
  • Loading branch information
kiwik committed Mar 23, 2023
1 parent 3b57431 commit 8d84c74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 7 additions & 8 deletions python/cloudtik/providers/_private/huaweicloud/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
from cloudtik.providers._private.huaweicloud.utils import _get_node_info, \
_make_ecs_client, _make_obs_client, \
_make_vpc_client, export_huaweicloud_obs_storage_config, flat_tags_map, \
get_huaweicloud_obs_storage_config, \
get_huaweicloud_cloud_storage_uri, get_huaweicloud_obs_storage_config, \
get_huaweicloud_obs_storage_config_for_update, HWC_OBS_BUCKET, \
HWC_SERVER_STATUS_ACTIVE, make_ecs_client, \
make_eip_client, \
Expand Down Expand Up @@ -1075,13 +1075,12 @@ def get_huaweicloud_workspace_info(config):
bucket_name = _get_managed_obs_bucket(obs_client, workspace_name)

if bucket_name:
resp = obs_client.getBucketLocation(bucket_name)
if resp.status < 300:
managed_cloud_storage_uri = resp.body.location
managed_cloud_storage = {
HWC_MANAGED_CLOUD_STORAGE_OBS_BUCKET: bucket_name,
CLOUDTIK_MANAGED_CLOUD_STORAGE_URI: managed_cloud_storage_uri}
info[CLOUDTIK_MANAGED_CLOUD_STORAGE] = managed_cloud_storage
obs_bucket_uri = get_huaweicloud_cloud_storage_uri(
{HWC_OBS_BUCKET: bucket_name})
managed_cloud_storage = {
HWC_MANAGED_CLOUD_STORAGE_OBS_BUCKET: bucket_name,
CLOUDTIK_MANAGED_CLOUD_STORAGE_URI: obs_bucket_uri}
info[CLOUDTIK_MANAGED_CLOUD_STORAGE] = managed_cloud_storage

return info

Expand Down
5 changes: 4 additions & 1 deletion python/cloudtik/providers/_private/huaweicloud/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def _client_cache(region: str = None, ak: str = None, sk: str = None) -> Dict[
server=OBS_SERVICES_URL, ssl_verify=_ssl_verify,
region=region)
else:
obs_client = ObsClient(server=OBS_SERVICES_URL, ssl_verify=_ssl_verify,
# Enable OBSClient (ENV, ECS) security provider policy chain, see
# https://support.huaweicloud.com/sdk-python-devg-obs/obs_22_0601.html
obs_client = ObsClient(security_provider_policy='OBS_DEFAULT',
server=OBS_SERVICES_URL, ssl_verify=_ssl_verify,
region=region)
client_map['obs'] = obs_client

Expand Down

0 comments on commit 8d84c74

Please sign in to comment.