Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
dcbb919
Initial changes for brownfield support.
abhijeetkaurav1st Apr 7, 2021
8bdd8e5
Adding substrate account_uuid mapping to brownfield vm instances
abhijeetkaurav1st Apr 9, 2021
a695196
bps module improvements
abhijeetkaurav1st Apr 12, 2021
5fa4c9a
Show account information in describe bp
abhijeetkaurav1st Apr 12, 2021
f3937c2
Add feature_min_version on cli options.
abhijeetkaurav1st Apr 12, 2021
933a391
Updated the message and adding the tests
abhijeetkaurav1st Apr 15, 2021
d1df7a5
Added tcs for CALM-14018
imranpasha1 Jun 17, 2021
f1d7383
formatted the code
imranpasha1 Jun 18, 2021
ec9a2bd
Brownfield response has been changed for vmware provider forom 3.3 on…
abhijeetkaurav1st Jun 18, 2021
baa0d5b
Merge pull request #46 from ideadevice/task/automate-calm-14018
abhijeetkaurav1st Jun 21, 2021
98693aa
use LV for version comparison
abhijeetkaurav1st Jul 19, 2021
eabad10
Merge pull request #47 from ideadevice/task/m-calm-25851-brownfield-v…
abhijeetkaurav1st Jul 19, 2021
9bcdd7d
Fix for running sync-repo github action only for public repo.
abhijeetkaurav1st Jul 19, 2021
aa4e15d
Adding release-notes for 3.3.0
abhijeetkaurav1st Jul 19, 2021
021d525
Merge branch 'master' into task/m-calm-19840-brownfield-changes
abhijeetkaurav1st Jul 19, 2021
7a1fbdf
Fix lint
abhijeetkaurav1st Jul 22, 2021
a349950
Minor import flake8 fix
abhijeetkaurav1st Jul 22, 2021
3d9302a
Use sys.exit with proper error message
abhijeetkaurav1st Jul 22, 2021
a7d48ae
Increased the gc installation time to 300s.
abhijeetkaurav1st Jul 29, 2021
3f3da44
Fixing blueprint file for brownfield tc
abhijeetkaurav1st Jul 29, 2021
7a1ad0d
Enabling check-login
abhijeetkaurav1st Jul 30, 2021
4fd03d4
Adding changes for rp integration
abhijeetkaurav1st Aug 3, 2021
b2675fd
Removing flake8 tests
abhijeetkaurav1st Aug 3, 2021
bd28432
Upgrading rp version due to https://github.com/reportportal/agent-pyt…
abhijeetkaurav1st Aug 3, 2021
56b27d4
Adding calm as project
abhijeetkaurav1st Aug 4, 2021
e0aeb49
Set log only when rp is enabled
abhijeetkaurav1st Aug 4, 2021
5cbd471
make black format
abhijeetkaurav1st Aug 4, 2021
9200b23
Merge pull request #52 from ideadevice/task/m-rp-integration-for-test
abhijeetkaurav1st Aug 4, 2021
6395893
Merge remote-tracking branch 'upstream/master'
abhijeetkaurav1st Aug 5, 2021
777f59a
Merge branch 'master' into task/m-calm-19840-brownfield-changes
abhijeetkaurav1st Aug 5, 2021
6b5cfa1
Add changes description in readme
abhijeetkaurav1st Aug 5, 2021
5847a52
Add correct pytest failure
abhijeetkaurav1st Aug 5, 2021
8a75d13
Merge pull request #41 from ideadevice/task/m-calm-19840-brownfield-c…
abhijeetkaurav1st Aug 5, 2021
a6f5771
safe remove
abhijeetkaurav1st Aug 9, 2021
24c616a
Topic/m multivm snapshot changes calm 18417 (#57)
mayank271 Aug 17, 2021
cc3fdb4
Task/m calm 27024 runbook containing durga macros (#58) (#59)
abhijeetkaurav1st Aug 19, 2021
95f3390
Substrate changes for sending account_uuid for ahv_substrates (#56) (…
abhijeetkaurav1st Aug 19, 2021
8ad8e08
protection policy fixes (#60) (#62)
mayank271 Aug 23, 2021
5c9395e
safety checks for protection rule expiry (#64) (#65)
mayank271 Sep 1, 2021
979aa37
fix expiry type in cache (#66) (#67)
mayank271 Sep 1, 2021
a6ce146
Fix template_id issue when there is no template for vmware create spe…
bhati-pradeep Sep 9, 2021
f68e3eb
ignoring VPC subnets (#70) (#74)
anilkumarkondeti Sep 9, 2021
fef58ac
Using common helper for waiting for non-busy state (#71)
abhijeetkaurav1st Sep 13, 2021
4d4da6b
Skipping runbook test due to CALM-27162
abhijeetkaurav1st Sep 15, 2021
905fce3
Task/m calm 20742 vm recovery point changes (#76)
abhijeetkaurav1st Oct 17, 2021
b4162cd
Merge pull request #85 from ideadevice/task/3.3.0-cherrypick-calm-207…
abhijeetkaurav1st Oct 17, 2021
469fd80
Add interface and implementations for aws provider specific api objec…
bhati-pradeep Oct 22, 2021
ba9b246
snapshot-restore release notes for 3.3.0 (#75) (#91)
Nov 2, 2021
370c975
App edit DSL support (#43) (#92)
gaurav1068 Nov 2, 2021
3de448f
Minor fixes regarding release-notes and some command name fixes
abhijeetkaurav1st Nov 3, 2021
4797f32
Black format
abhijeetkaurav1st Nov 3, 2021
95bb44e
Fixing some brownfield and env fixes
abhijeetkaurav1st Nov 8, 2021
36dfaf1
Merge branch 'release/3.3.0' of github.com:ideadevice/calm-dsl into r…
abhijeetkaurav1st Nov 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/sync-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
build:
if: ${{ github.repository == 'nutanix/calm-dsl' }}
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ clean:
[ -S /var/run/docker.sock ] && \
docker ps -aq --no-trunc --filter "status=exited" | xargs -I {} docker rm {} && \
docker image prune -f
rm -r venv/ && mkdir venv/ && touch venv/.empty
rm -rf venv/ && mkdir venv/ && touch venv/.empty

test-verbose: dev
venv/bin/py.test -s -vv
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Context info includes server, project and log configuration for dsl operations.
- List Brownfield vms: `calm get brownfield vms --project <project_name> --type [AHV_VM|AWS_VM|AZURE_VM|GCP_VM|VMWARE_VM]`. Please use `--account` cli option, if project has multiple accounts for a provider type.
- Compile Blueprint: `calm compile bp -f <blueprint_file_location> -b <brownfield_deployments_file_location>`.
- Create Brownfield Application: `calm create app -f <bluprint_file_location> -b <brownfield_deployments_file_location> -n <app_name> -i`.
- Create Brownfield Application using existing blueprint: `calm launch bp <bp_name> -b <brownfield_deployments_file_location> -n <app_name>`. Command will launch existing blueprint to create brownfield application (3.3.0 onwards). Look at sample file [here](examples/Brownfield/separate_file_example/brownfield_deployments.py).

### Decompiling Blueprints (`.json`->`.py`)
Decompilation is process to consume json data for any entity and convert it back to dsl python helpers/classes. Currently, decompile is supported for converting blueprint json to python files. Summary of support for blueprint decompilation(Experimental feature):
Expand Down
8 changes: 8 additions & 0 deletions calm/dsl/api/app_protection_policy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .resource import ResourceAPI


class AppProtectionPolicyAPI(ResourceAPI):
def __init__(self, connection):
super().__init__(
connection, resource_type="app_protection_policies", calm_api=True
)
20 changes: 20 additions & 0 deletions calm/dsl/api/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ def __init__(self, connection):
super().__init__(connection, resource_type="apps")

self.ACTION_RUN = self.ITEM + "/actions/{}/run"
self.PATCH_RUN = self.ITEM + "/patch/{}/run"
self.DOWNLOAD_RUNLOG = self.ITEM + "/app_runlogs/{}/output/download"
self.ACTION_VARIABLE = self.ITEM + "/actions/{}/variables"
self.RECOVERY_GROUPS_LIST = self.ITEM + "/recovery_groups/list"

def run_action(self, app_id, action_id, payload):
return self.connection._call(
Expand All @@ -18,6 +20,14 @@ def run_action(self, app_id, action_id, payload):
method=REQUEST.METHOD.POST,
)

def run_patch(self, app_id, patch_id, payload):
return self.connection._call(
self.PATCH_RUN.format(app_id, patch_id),
request_json=payload,
verify=False,
method=REQUEST.METHOD.POST,
)

def poll_action_run(self, poll_url, payload=None):
if payload:
return self.connection._call(
Expand Down Expand Up @@ -47,3 +57,13 @@ def action_variables(self, app_id, action_name):
return self.connection._call(
action_var_url, method=REQUEST.METHOD.GET, verify=False
)

def get_recovery_groups(self, app_id, api_filter, length=250, offset=0):
payload = {"filter": api_filter, "length": length, "offset": offset}
recovery_groups_url = self.RECOVERY_GROUPS_LIST.format(app_id)
return self.connection._call(
recovery_groups_url,
request_json=payload,
verify=False,
method=REQUEST.METHOD.POST,
)
18 changes: 18 additions & 0 deletions calm/dsl/api/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def __init__(self, connection):
self.VARIABLE_VALUES_WITH_TRLID = (
self.VARIABLE_VALUES + "?requestId={}&trlId={}"
)
self.PROTECTION_POLICY_LIST = (
self.ITEM + "/app_profile/{}/config_spec/{}/app_protection_policies/list"
)

# TODO https://jira.nutanix.com/browse/CALM-17178
# Blueprint creation timeout is dependent on payload.
Expand Down Expand Up @@ -88,6 +91,21 @@ def brownfield_vms(self, payload):
method=REQUEST.METHOD.POST,
)

def protection_policies(
self, bp_uuid, app_profile_uuid, config_uuid, env_uuid, length=250, offset=0
):
payload = {
"length": 250,
"offset": 0,
"filter": "environment_references=={}".format(env_uuid),
}
return self.connection._call(
self.PROTECTION_POLICY_LIST.format(bp_uuid, app_profile_uuid, config_uuid),
verify=False,
request_json=payload,
method=REQUEST.METHOD.POST,
)

@staticmethod
def _make_blueprint_payload(bp_name, bp_desc, bp_resources, bp_metadata=None):

Expand Down
6 changes: 6 additions & 0 deletions calm/dsl/api/handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from .role import RoleAPI
from .directory_service import DirectoryServiceAPI
from .access_control_policy import AccessControlPolicyAPI
from .app_protection_policy import AppProtectionPolicyAPI
from .vm_recovery_point import VmRecoveryPointAPI
from .nutanix_task import TaskAPI


class ClientHandle:
Expand Down Expand Up @@ -52,6 +55,9 @@ def _connect(self):
self.directory_service = DirectoryServiceAPI(self.connection)
self.acp = AccessControlPolicyAPI(self.connection)
self.environment = EnvironmentAPI(self.connection)
self.app_protection_policy = AppProtectionPolicyAPI(self.connection)
self.vm_recovery_point = VmRecoveryPointAPI(self.connection)
self.nutanix_task = TaskAPI(self.connection)


def get_client_handle_obj(
Expand Down
6 changes: 6 additions & 0 deletions calm/dsl/api/nutanix_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .resource import ResourceAPI


class TaskAPI(ResourceAPI):
def __init__(self, connection):
super().__init__(connection, resource_type="tasks")
9 changes: 5 additions & 4 deletions calm/dsl/api/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
class ResourceAPI:

ROOT = "api/nutanix/v3"
CALM_ROOT = "api/calm/v3.0"

def __init__(self, connection, resource_type):
def __init__(self, connection, resource_type, calm_api=False):
self.connection = connection
self.PREFIX = ResourceAPI.ROOT + "/" + resource_type
self.PREFIX = (self.CALM_ROOT if calm_api else self.ROOT) + "/" + resource_type
self.LIST = self.PREFIX + "/list"
self.ITEM = self.PREFIX + "/{}"

Expand Down Expand Up @@ -120,5 +121,5 @@ def list_all(self, api_limit=250):
return final_list


def get_resource_api(resource_type, connection):
return ResourceAPI(connection, resource_type)
def get_resource_api(resource_type, connection, calm_api=False):
return ResourceAPI(connection, resource_type, calm_api=calm_api)
6 changes: 6 additions & 0 deletions calm/dsl/api/vm_recovery_point.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .resource import ResourceAPI


class VmRecoveryPointAPI(ResourceAPI):
def __init__(self, connection):
super().__init__(connection, resource_type="nutanix/v1/vm_recovery_points")
15 changes: 14 additions & 1 deletion calm/dsl/builtins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from .models.provider_spec import provider_spec, read_provider_spec, read_spec
from .models.provider_spec import read_ahv_spec, read_vmw_spec
from .models.readiness_probe import ReadinessProbe, readiness_probe, ReadinessProbeType

from .models.ahv_vm_nic import ahv_vm_nic, AhvVmNic, AhvNicType
from .models.ahv_vm_disk import ahv_vm_disk, AhvVmDisk, AhvDiskType
from .models.ahv_vm_gpu import ahv_vm_gpu, AhvVmGpu, AhvGpuType
Expand All @@ -47,13 +46,24 @@
AhvVmType,
AhvVmResourcesType,
)
from .models.ahv_recovery_vm import AhvVmRecoveryResources, ahv_vm_recovery_spec

from .models.substrate import Substrate, substrate, SubstrateType
from .models.deployment import Deployment, deployment, DeploymentType
from .models.pod_deployment import PODDeployment, pod_deployment

from .models.config_attrs import AhvUpdateConfigAttrs, PatchDataField
from .models.app_protection import AppProtection
from .models.config_spec import ConfigSpecType
from .models.app_edit import AppEdit
from .models.patch_field import PatchField

from .models.profile import Profile, profile, ProfileType

from .models.config_spec import (
UpdateConfig,
)

from .models.blueprint import Blueprint, blueprint, BlueprintType

from .models.simple_deployment import SimpleDeployment
Expand Down Expand Up @@ -180,4 +190,7 @@
"Endpoint",
"_endpoint",
"CalmEndpoint",
"AppProtection",
"AhvVmRecoveryResources",
"ahv_vm_recovery_spec",
]
67 changes: 67 additions & 0 deletions calm/dsl/builtins/models/ahv_recovery_vm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import sys
import uuid

from .entity import Entity, EntityType
from .validator import PropertyValidator
from .helper import common as common_helper
from .ahv_vm import AhvVmResourcesType

from calm.dsl.store import Cache
from calm.dsl.constants import CACHE
from calm.dsl.api.handle import get_api_client
from calm.dsl.log import get_logging_handle


LOG = get_logging_handle(__name__)


# AhvRecoveryVm


class AhvVMRecoveryResourcesType(AhvVmResourcesType):
"""Metaclass for ahv vm recovery resources"""

__schema_name__ = "AhvVmRecoveryResources"
__openapi_type__ = "recovery_vm_ahv_resources"


class AhvVMRecoveryResourcesValidator(
PropertyValidator, openapi_type="recovery_vm_ahv_resources"
):
__default__ = None
__kind__ = AhvVMRecoveryResourcesType


def _ahv_vm_recovery_resources(**kwargs):
name = kwargs.get("name", None)
bases = (Entity,)
return AhvVMRecoveryResourcesType(name, bases, kwargs)


AhvVmRecoveryResources = _ahv_vm_recovery_resources()


# AhvVmRecoverySpec


class AhvVMRecoverySpecType(EntityType):
"""Metaclass for ahv vm recovery resources"""

__schema_name__ = "AhvVmRecoverySpec"
__openapi_type__ = "recovery_vm_ahv_spec"


class AhvVMRecoverySpecValidator(
PropertyValidator, openapi_type="recovery_vm_ahv_spec"
):
__default__ = None
__kind__ = AhvVMRecoverySpecType


def ahv_vm_recovery_spec(**kwargs):
name = kwargs.get("name", None)
bases = (Entity,)
return AhvVMRecoverySpecType(name, bases, kwargs)


AhvVMRecoverySpec = ahv_vm_recovery_spec()
25 changes: 15 additions & 10 deletions calm/dsl/builtins/models/ahv_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,30 @@ def compile(cls):

# Merging boot_type to boot_config
cdict["boot_config"] = boot_config
boot_type = cdict.pop("boot_type")
boot_type = cdict.pop("boot_type", None)
if boot_type == "UEFI":
cdict["boot_config"]["boot_type"] = "UEFI"

if not cdict["boot_config"]:
cdict.pop("boot_config", None)

serial_port_list = []
for ind, connection_status in cdict["serial_port_list"].items():
if not isinstance(ind, int):
raise TypeError("index {} is not of type integer".format(ind))

if not isinstance(connection_status, bool):
raise TypeError(
"connection status {} is not of type bool".format(connection_status)
if cdict.get("serial_port_list"):
for ind, connection_status in cdict["serial_port_list"].items():
if not isinstance(ind, int):
raise TypeError("index {} is not of type integer".format(ind))

if not isinstance(connection_status, bool):
raise TypeError(
"connection status {} is not of type bool".format(
connection_status
)
)

serial_port_list.append(
{"index": ind, "is_connected": connection_status}
)

serial_port_list.append({"index": ind, "is_connected": connection_status})

cdict["serial_port_list"] = serial_port_list

return cdict
Expand Down
12 changes: 3 additions & 9 deletions calm/dsl/builtins/models/ahv_vm_nic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ def compile(cls):

if not subnet_cache_data:
LOG.debug(
"Ahv Subnet (name = '{}') not found in registered Nutanix PC account (uuid = '{}') "
"in project (name = '{}')".format(
subnet_name, account_uuid, project["name"]
"Ahv Subnet (name = '{}') not found in registered Nutanix PC account (uuid = '{}') ".format(
subnet_name, account_uuid
)
)
LOG.error(
"AHV Subnet {} not found. Please run: calm update cache".format(
subnet_name
)
)
sys.exit(-1)
sys.exit("AHV Subnet {} not found.".format(subnet_name))

subnet_uuid = subnet_cache_data.get("uuid", "")

Expand Down
31 changes: 31 additions & 0 deletions calm/dsl/builtins/models/app_edit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys

from calm.dsl.log import get_logging_handle

from .config_spec import patch_config_create

LOG = get_logging_handle(__name__)


class AppEdit:
def __new__(cls, *args, **kwargs):
raise TypeError("'{}' is not callable".format(cls.__name__))

class UpdateConfig:
def __new__(
cls,
name,
target,
patch_attrs,
):
if target.__self__.substrate.__self__.provider_type != "AHV_VM":
LOG.error(
"Config is not supported for {} provider. Please try again after changing the provider".format(
target.__self__.substrate.__self__.provider_type
)
)
return patch_config_create(
name,
target=target,
patch_attrs=patch_attrs,
)
Loading