Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Huawei Cloud: Add workspace functions for HuaweiCloud provider (#1113)
Browse files Browse the repository at this point in the history
1. Create and delete workspace networking resources and cloud storage.
2. Add HUAWEI CLOUD SDK package into setup.py and requirements.txt.
3. Add HUAWEI CLOUD default config files, and update schema.

Related-with: #1011
  • Loading branch information
kiwik authored Feb 16, 2023
1 parent 70f855f commit ef13732
Show file tree
Hide file tree
Showing 13 changed files with 1,422 additions and 1 deletion.
27 changes: 27 additions & 0 deletions python/cloudtik/core/_private/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def _import_kubernetes(provider_config):
return KubernetesNodeProvider


# TODO(ChenRui): implement NodeProvider
def _import_huaweicloud(provider_config):
from cloudtik.providers._private.huaweicloud.node_provider import \
HUAWEICLOUDNodeProvider
return HUAWEICLOUDNodeProvider


def _load_local_provider_home():
import cloudtik.providers.local as local_provider
return os.path.dirname(local_provider.__file__)
Expand Down Expand Up @@ -86,6 +93,11 @@ def _load_aliyun_provider_home():
return os.path.dirname(aliyun_provider.__file__)


def _load_huaweicloud_provider_home():
import cloudtik.providers.huaweicloud as huaweicloud_provider
return os.path.dirname(huaweicloud_provider.__file__)


def _load_local_defaults_config():
return os.path.join(_load_local_provider_home(), "defaults.yaml")

Expand All @@ -110,6 +122,10 @@ def _load_aliyun_defaults_config():
return os.path.join(_load_aliyun_provider_home(), "defaults.yaml")


def _load_huaweicloud_defaults_config():
return os.path.join(_load_huaweicloud_provider_home(), "defaults.yaml")


def _import_external(provider_config):
provider_cls = _load_class(path=provider_config["provider_class"])
return provider_cls
Expand All @@ -122,6 +138,7 @@ def _import_external(provider_config):
"azure": _import_azure,
"aliyun": _import_aliyun,
"kubernetes": _import_kubernetes,
"huaweicloud": _import_huaweicloud,
"external": _import_external # Import an external module
}

Expand All @@ -132,6 +149,7 @@ def _import_external(provider_config):
"azure": "Azure",
"aliyun": "Aliyun",
"kubernetes": "Kubernetes",
"huaweicloud": "HUAWEI CLOUD",
"external": "External"
}

Expand All @@ -142,6 +160,7 @@ def _import_external(provider_config):
"azure": _load_azure_provider_home,
"aliyun": _load_aliyun_provider_home,
"kubernetes": _load_kubernetes_provider_home,
"huaweicloud": _load_huaweicloud_provider_home,
}

_DEFAULT_CONFIGS = {
Expand All @@ -151,6 +170,7 @@ def _import_external(provider_config):
"azure": _load_azure_defaults_config,
"aliyun": _load_aliyun_defaults_config,
"kubernetes": _load_kubernetes_defaults_config,
"huaweicloud": _load_huaweicloud_defaults_config,
}

# For caching workspace provider instantiations across API calls of one python session
Expand Down Expand Up @@ -189,13 +209,20 @@ def _import_kubernetes_workspace(provider_config):
return KubernetesWorkspaceProvider


def _import_huaweicloud_workspace(provider_config):
from cloudtik.providers._private.huaweicloud.workspace_provider import \
HUAWEICLOUDWorkspaceProvider
return HUAWEICLOUDWorkspaceProvider


_WORKSPACE_PROVIDERS = {
"local": _import_local_workspace,
"aws": _import_aws_workspace,
"gcp": _import_gcp_workspace,
"azure": _import_azure_workspace,
"aliyun": _import_aliyun_workspace,
"kubernetes": _import_kubernetes_workspace,
"huaweicloud": _import_huaweicloud_workspace,
"external": _import_external # Import an external module
}

Expand Down
18 changes: 17 additions & 1 deletion python/cloudtik/core/workspace-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"properties": {
"type": {
"type": "string",
"description": "e.g. aws, azure, gcp, aliyun..."
"description": "e.g. aws, azure, gcp, aliyun, huaweicloud..."
},
"region": {
"type": "string",
Expand Down Expand Up @@ -175,6 +175,22 @@
}
}
},
"huaweicloud_credentials": {
"type": "object",
"description": "Credentials for authenticating with HUAWEI CLOUD. If not specified, will use environment default.",
"required": [ "huaweicloud_access_key", "huaweicloud_secret_key" ],
"additionalProperties": false,
"properties": {
"huaweicloud_access_key": {
"type": "string",
"description": "The access key to use when creating the client."
},
"huaweicloud_secret_key": {
"type": "string",
"description": "The secret key to use when creating the client."
}
}
},
"managed_cloud_storage": {
"type": "boolean",
"description": "Whether to create managed cloud storage of workspace.",
Expand Down
Empty file.
Loading

0 comments on commit ef13732

Please sign in to comment.