Skip to content

Commit

Permalink
Merge pull request #295 from nutanix/dsl-release-3722-beta
Browse files Browse the repository at this point in the history
CALM-DSL changes for v3.7.2.2
  • Loading branch information
abhijeetkaurav1st authored Apr 25, 2024
2 parents 744ef74 + c5e7960 commit 4d2ebbb
Show file tree
Hide file tree
Showing 207 changed files with 9,987 additions and 2,081 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: black
if: ${{matrix.python-version != '3.7'}}
uses: psf/black@stable # Exclude list is not honored - https://github.com/psf/black/issues/1584
with:
version: "22.6.0"
Expand Down
2 changes: 1 addition & 1 deletion CalmVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.2.1
3.7.2.2
401 changes: 401 additions & 0 deletions Documentation/docs/models/runbook/ndb_task.md

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ Use `calm get roles` to list all roles in PC. The below roles are relevant for C

### Projects
- Compile project: `calm compile project --file <project_file_location>`. This command will print the compiled project JSON. Look at sample file [here](examples/Project/demo_project.py) and [here](examples/Project/project_with_env.py).
- Create project on Calm Server: `calm create project --file <project_file_location> --name <project_name> --description <description>`. Use `no-cache-update` flag to skip cache updations post operation.
- Create project on Calm Server: `calm create project --file <project_file_location> --name <project_name> --description <description>`.\
**Options:**\
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `--no-cache-update`: flag to skip cache updations post operation.\
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `--force`: flag to delete existing project with the same name before create, if entities are not associated with it.

- List projects: `calm get projects`. Get projects, optionally filtered by a string
- Describe project: `calm describe project <project_name>`. It will print summary of project.
- Update project using dsl file: `calm update project <project_name> --file <project_file_location>`. Environments will not be updated as part of this operation. Use `no-cache-update` flag to skip cache updations post operation.
Expand All @@ -162,13 +166,22 @@ Use `calm get roles` to list all roles in PC. The below roles are relevant for C
- If the project already has quotas set and enabled and there are no quotas in {project_file} then the original quotas in the projects would be persisted.
- If the project doesn't have quotas enabled/set and the {project_file} has quotas then the quotas would be enabled and set in the project.
- Note: While using `no-cache-update` flag in project create and update commands, user should not pass environment object in the project model. User should update the cache separately after creation/updation of projects. Feature is experimental and will be discontinued after [#184](https://github.com/nutanix/calm-dsl/issues/184) is fixed.
- Decompile existing server project: `calm decompile project <project_name>`.
- Decompile project from existing json file: `calm decompile project --file <json_file_location>`.
- Decompile project to a location: `calm decompile project <project_name> --dir <project_dir>`. It will decompile project entities to `project_dir` location.

### Environments
- Compile environment: `calm compile environment --file <env_file_location> --project <project_name>`. Command will print the compiled environment JSON. Look at sample file [here](examples/Environment/sample_environment.py)
- Create environment to existing project: `calm create environment --file <env_file_location> --project <project_name> --name <environmet_name>`. Use `no-cache-update` flag to skip cache updations post operation.
- Create environment to existing project: `calm create environment --file <env_file_location> --project <project_name> --name <environmet_name>`.\
**Options:**\
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `--no-cache-update`: flag to skip cache updations post operation.\
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `--force`: flag to delete existing environment in a project with the same name before create, if entities are not associated with it.
- Update environment: `calm update environment <environment_name> --file <env_file_location> --project <project_name>`. Use `no-cache-update` flag to skip cache updations post operation.
- List environments: `calm get environments --project <project_name>`. Get environments of project.
- Delete environment: `calm delete environment <environment_name> --project <project_name>`. Use `no-cache-update` flag to skip cache updations post operation.
- Decompile existing server environment: `calm decompile environment <environment_name> --project <project_name>`.
- Decompile environment from existing json file: `calm decompile environment --file <json_file_location> --project <project_name>`.
- Decompile environment to a location: `calm decompile environment <environment_name> --project <project_name> --dir <environment_dir>`. It will decompile environment entities to `environment_dir` location.

### Access Control Policies
Access control policies ensures that a project member can access only the entities or perform only the actions defined in the role assigned to that project member.
Expand Down
3 changes: 2 additions & 1 deletion calm/dsl/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .handle import get_client_handle_obj, get_api_client
from .handle import get_client_handle_obj, get_api_client, reset_api_client_handle
from .resource import get_resource_api

__all__ = [
"get_client_handle_obj",
"get_api_client",
"get_resource_api",
"reset_api_client_handle",
]
37 changes: 35 additions & 2 deletions calm/dsl/api/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .util import (
strip_secrets,
patch_secrets,
strip_patch_config_tasks,
add_patch_config_tasks,
)
from calm.dsl.log import get_logging_handle

Expand Down Expand Up @@ -191,6 +193,8 @@ def upload_with_secrets(
bp_resources, secret_map, secret_variables, object_lists=object_lists
)

# Removing patch config tasks before uploading
profile_patch_config_tasks = strip_patch_config_tasks(bp_resources)
for obj_index, obj in enumerate(
bp_resources.get("substrate_definition_list", []) or []
):
Expand All @@ -210,10 +214,23 @@ def upload_with_secrets(
if err:
return res, err

# Add secrets and update bp
# Add secrets, patch config tasks and update bp
bp = res.json()
service_name_uuid_map = {}
app_profile_list = bp["status"].get("resources", {}).get("app_profile_list", [])
for service in (
bp["status"].get("resources", {}).get("service_definition_list", [])
):
service_name_uuid_map[service["name"]] = service["uuid"]
del bp["status"]

add_patch_config_tasks(
bp["spec"]["resources"],
app_profile_list,
profile_patch_config_tasks,
service_name_uuid_map,
)

patch_secrets(bp["spec"]["resources"], secret_map, secret_variables)

# Adding categories at PUT call to blueprint
Expand Down Expand Up @@ -273,6 +290,9 @@ def upload_with_decompiled_secrets(
not_stripped_secrets=not_stripped_secrets,
)

# Removing patch config tasks before uploading
profile_patch_config_tasks = strip_patch_config_tasks(bp_resources)

for obj_index, obj in enumerate(
bp_resources.get("substrate_definition_list", []) or []
):
Expand All @@ -299,10 +319,23 @@ def upload_with_decompiled_secrets(
if err:
return res, err

# Add secrets and update bp
# Add secrets, patch config tasks and update bp
bp = res.json()
service_name_uuid_map = {}
app_profile_list = bp["status"].get("resources", {}).get("app_profile_list", [])
for service in (
bp["status"].get("resources", {}).get("service_definition_list", [])
):
service_name_uuid_map[service["name"]] = service["uuid"]
del bp["status"]

add_patch_config_tasks(
bp["spec"]["resources"],
app_profile_list,
profile_patch_config_tasks,
service_name_uuid_map,
)

LOG.info("Patching newly created/updated secrets")
for k in secret_map:
LOG.debug("[CREATED/MODIFIED] credential -> '{}'".format(k))
Expand Down
7 changes: 7 additions & 0 deletions calm/dsl/api/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,10 @@ def get_api_client():
update_api_client(host=pc_ip, port=pc_port, auth=(username, password))

return _API_CLIENT_HANDLE


def reset_api_client_handle():
"""resets global api client object (_API_CLIENT_HANDLE)"""

global _API_CLIENT_HANDLE
_API_CLIENT_HANDLE = None
Loading

0 comments on commit 4d2ebbb

Please sign in to comment.