Skip to content

Commit

Permalink
Add workspace functions for HuaweiCloud provider
Browse files Browse the repository at this point in the history
1. Create and delete workspace networking resources
2. Add HUAWEICLOUD SDK package into setup.py and requirements.txt
3. Add HUAWEICLOUD default config files, and update schema.

Related-with: oap-project#1011
  • Loading branch information
kiwik committed Feb 7, 2023
1 parent 658594c commit dae5f22
Show file tree
Hide file tree
Showing 13 changed files with 1,094 additions and 2 deletions.
27 changes: 27 additions & 0 deletions python/cloudtik/core/_private/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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 All @@ -76,6 +83,11 @@ def _load_azure_provider_home():
return os.path.dirname(azure_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 @@ -96,6 +108,10 @@ def _load_azure_defaults_config():
return os.path.join(_load_azure_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 @@ -107,6 +123,7 @@ def _import_external(provider_config):
"gcp": _import_gcp,
"azure": _import_azure,
"kubernetes": _import_kubernetes,
"huaweicloud": _import_huaweicloud,
"external": _import_external # Import an external module
}

Expand All @@ -116,6 +133,7 @@ def _import_external(provider_config):
"gcp": "GCP",
"azure": "Azure",
"kubernetes": "Kubernetes",
"huaweicloud": "HUAWEICLOUD",
"external": "External"
}

Expand All @@ -125,6 +143,7 @@ def _import_external(provider_config):
"gcp": _load_gcp_provider_home,
"azure": _load_azure_provider_home,
"kubernetes": _load_kubernetes_provider_home,
"huaweicloud": _load_huaweicloud_provider_home,
}

_DEFAULT_CONFIGS = {
Expand All @@ -133,6 +152,7 @@ def _import_external(provider_config):
"gcp": _load_gcp_defaults_config,
"azure": _load_azure_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 @@ -166,12 +186,19 @@ 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,
"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,..."
"description": "e.g. aws, azure, gcp, huaweicloud,..."
},
"region": {
"type": "string",
Expand Down Expand Up @@ -159,6 +159,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 dae5f22

Please sign in to comment.