Skip to content

Commit

Permalink
Merge pull request #269 from cloudify-cosmo/3.8.3-build
Browse files Browse the repository at this point in the history
3.8.3 build
  • Loading branch information
EarthmanT authored Apr 9, 2023
2 parents e427857 + 2333576 commit 250a2d9
Show file tree
Hide file tree
Showing 17 changed files with 190 additions and 2,411 deletions.
24 changes: 13 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,30 @@ commands:

run_hello_world_test:
steps:
- run: ecosystem-test local-blueprint-test -b examples/blueprint-examples/hello-world-example/azure.yaml --test-id=hello-world-example -i env_name=azpl -i resource_suffix=test$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=1800 | tee -a run_hello_world_test.log
- run: ecosystem-test local-blueprint-test -b examples/blueprint-examples/hello-world-example/azure.yaml --test-id=hello-world-example -i env_name=azpl -i resource_suffix=test$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=1800 | tee -a run_hello_world_test.log
- store_artifacts:
path: run_hello_world_test.log
- slack/notify_failed

run_azure_arm_test:
steps:
- run: ecosystem-test local-blueprint-test -b examples/blueprint-examples/virtual-machine/azure-arm.yaml --test-id=virtual-machine -i env_name=azpl -i resource_suffix=test$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=1800 | tee -a run_azure_arm_test.log
- run: ecosystem-test local-blueprint-test -b examples/blueprint-examples/virtual-machine/azure-arm.yaml --test-id=virtual-machine -i env_name=azpl -i resource_suffix=test$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=1800 | tee -a run_azure_arm_test.log
- store_artifacts:
path: run_azure_arm_test.log
- slack/notify_failed

run_aks_test:
steps:
- run: ecosystem-test local-blueprint-test -b examples/blueprint-examples/kubernetes/azure-aks/blueprint.yaml --test-id=azure-aks -i env_name=it --on-failure=uninstall-force --timeout=3000 | tee -a run_aks_test.log
- run: |
export ENV_NAME=t${CIRCLE_BUILD_NUM: -2}
ecosystem-test local-blueprint-test -b examples/blueprint-examples/kubernetes/azure-aks/blueprint.yaml --test-id=azure-aks -i env_name=$ENV_NAME --on-failure=uninstall-force --timeout=3000 | tee -a run_aks_test.log
- store_artifacts:
path: run_aks_test.log
- slack/notify_failed

run_lb_test:
steps:
- run: ecosystem-test local-blueprint-test -b examples/load-balancer-blueprint.yaml --test-id=azure-aks -i resource_prefix=lb-test-$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=3000 | tee -a run_lb_test.log
- run: ecosystem-test local-blueprint-test -b examples/load-balancer-blueprint.yaml --test-id=azure-aks -i resource_prefix=lb-test-$CIRCLE_BUILD_NUM --on-failure=uninstall-force --timeout=3000 | tee -a run_lb_test.log
- store_artifacts:
path: run_lb_test.log
- slack/notify_failed
Expand Down Expand Up @@ -140,7 +142,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- hw_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand All @@ -151,7 +153,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- azure_arm_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand All @@ -162,7 +164,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- aks_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand Down Expand Up @@ -213,7 +215,7 @@ workflows:
jobs:
- node/check_py3_compat_job
- node/unittests_job:
context:
context:
- slack-secrets
<<: *unittest-post-steps
- node/validate_version_job
Expand All @@ -230,7 +232,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- hw_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand All @@ -241,7 +243,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- azure_arm_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand All @@ -252,7 +254,7 @@ workflows:
branches:
only: /([0-9\.]*\-build|master|dev)/
- aks_integration_tests_py3:
context:
context:
- slack-secrets
<<: *unittest-post-steps
requires:
Expand Down
4 changes: 0 additions & 4 deletions .circleci/merge_docs.py

This file was deleted.

13 changes: 0 additions & 13 deletions .circleci/package_release.py

This file was deleted.

12 changes: 0 additions & 12 deletions .circleci/update_code.py

This file was deleted.

12 changes: 0 additions & 12 deletions .circleci/update_test_manager.py

This file was deleted.

4 changes: 0 additions & 4 deletions .circleci/validate_docs.py

This file was deleted.

12 changes: 0 additions & 12 deletions .circleci/validate_version.py

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
3.8.3: CYBL-1934 add Run Command operation
3.8.2: add __version__.py file in cloudify_azure folder.
3.8.1: RD 5834 define credentials in azure plugin yaml 1 5.
3.8.0:
Expand Down
17 changes: 17 additions & 0 deletions azure_sdk/resources/compute/virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,20 @@ def restart(self, group_name, vm_name):
restart_async_operation.wait()
self.logger.debug(
'Restarted virtual_machine {0}'.format(vm_name))

def run_command(self, group_name, vm_name, cmd_params):
self.logger.info(
"Running command on virtual_machine...{0}".format(vm_name))
run_cmd_async_operation = \
self.client.virtual_machines.begin_run_command(
resource_group_name=group_name,
vm_name=vm_name,
parameters=cmd_params)
run_cmd_async_operation.wait()
run_cmd = run_cmd_async_operation.result().as_dict()
self.logger.info(
'Run command result: {0}'.format(
utils.secure_logging_content(run_cmd))
)
self.logger.debug(
'Finished running command on virtual_machine {0}'.format(vm_name))
2 changes: 1 addition & 1 deletion cloudify_azure/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '3.8.2'
version = '3.8.3'
2 changes: 1 addition & 1 deletion cloudify_azure/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
# cloudify_azure/resources/compute/virtualmachine/virtualmachine_utils.py
# ::check_if_configuration_changed props list,
# according to api version.
API_VER_COMPUTE = '2016-03-30'
API_VER_COMPUTE = '2017-03-30'
API_VER_STORAGE_BLOB = '2015-12-11'
API_VER_CONTAINER = '2017-07-01'
API_VER_MANAGED_CLUSTER = '2018-03-31'
Expand Down
25 changes: 25 additions & 0 deletions cloudify_azure/resources/compute/virtualmachine/virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,3 +708,28 @@ def detach_data_disk(ctx, **_):
raise cfy_exc.NonRecoverableError(
"detach disk from virtual_machine '{0}' "
"failed with this error : {1}".format(name, cr.message))


@operation(resumable=True)
def run_command(ctx, command_id, script, params, **_):
"""Runs command on the Virtual Machine"""
azure_config = utils.get_client_config(ctx.node.properties)
resource_group_name = utils.get_resource_group(ctx)
name = ctx.instance.runtime_properties.get('name')
api_version = \
ctx.node.properties.get('api_version', constants.API_VER_COMPUTE)
vm_iface = VirtualMachine(azure_config, ctx.logger, api_version)
# Run command on the VM
run_cmd_params = {
'command_id': command_id,
'script': script,
'parameters': params
}
try:
vm_iface.run_command(resource_group_name,
name,
run_cmd_params)
except CloudError as cr:
raise cfy_exc.NonRecoverableError(
"Run command on virtual_machine '{0}' "
"failed with this error : {1}".format(name, cr.message))
32 changes: 31 additions & 1 deletion cloudify_azure/tests/resources/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_create(self, client, credentials):
)
client().availability_sets.create_or_update.assert_called_with(
resource_group_name=resource_group,
name=name,
availability_set_name=name,
parameters=availability_set_conf
)

Expand Down Expand Up @@ -550,3 +550,33 @@ def test_resize(self, client, credentials):
vm_name=name,
parameters=params
)

def test_run_command(self, client, credentials):

fake_ctx, _, __ = self._get_mock_context_for_run(
operation={'name': 'cloudify.interfaces.operations.run_command'})
fake_ctx.node.properties['azure_config'] = self.dummy_azure_credentials
resource_group = 'sample_resource_group'
name = 'mockvm'
params = {
'command_id': 'RunShellScript',
'script': ['echo "test"'],
'parameters': []
}
fake_ctx.instance.runtime_properties['resource_group'] = resource_group
fake_ctx.instance.runtime_properties['name'] = name
with mock.patch('cloudify_azure.utils.secure_logging_content',
mock.Mock()):
response = mock.MagicMock()
response.status_code = 200
client().virtual_machines.get.return_value = response
virtualmachine.run_command(ctx=fake_ctx,
command_id=params.get('command_id'),
script=params.get('script'),
params=params.get('parameters'))
client().virtual_machines.begin_run_command \
.assert_called_with(
resource_group_name=resource_group,
vm_name=name,
parameters=params
)
37 changes: 34 additions & 3 deletions plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins:
azure:
executor: central_deployment_agent
package_name: cloudify-azure-plugin
package_version: '3.8.2'
package_version: '3.8.3'

data_types:
cloudify.datatypes.azure.Config:
Expand Down Expand Up @@ -1205,7 +1205,7 @@ node_types:
type: string
description: >
Compute API Version
default: "2016-03-30"
default: "2017-03-30"
resource_group_name:
type: string
description: >
Expand Down Expand Up @@ -1292,6 +1292,21 @@ node_types:
type: string
description: The name of the VM size, according to https://docs.microsoft.com/en-us/azure/virtual-machines/sizes
default: ""
run_command:
implementation: azure.cloudify_azure.resources.compute.virtualmachine.virtualmachine.run_command
inputs:
command_id:
type: string
description: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command#available-commands
default: RunShellScript
script:
type: list
description: https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2022_08_01.models.runcommandinput?view=azure-python
default: []
parameters:
type: list
description: https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2022_08_01.models.runcommandinputparameter?view=azure-python
default: []

cloudify.azure.nodes.compute.WindowsVirtualMachine:
derived_from: cloudify.azure.nodes.compute.VirtualMachine
Expand All @@ -1312,7 +1327,23 @@ node_types:
file_uris:
default:
- https://raw.githubusercontent.com/cloudify-cosmo/cloudify-azure-plugin/master/scripts/ps_enable_winrm_http.ps1

cloudify.interfaces.operations:
run_command:
implementation: azure.cloudify_azure.resources.compute.virtualmachine.virtualmachine.run_command
inputs:
command_id:
type: string
description: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/run-command#available-commands
default: RunPowerShellScript
script:
type: list
description: https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2022_08_01.models.runcommandinput?view=azure-python
default: []
parameters:
type: list
description: https://learn.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2022_08_01.models.runcommandinputparameter?view=azure-python
default: []

cloudify.azure.nodes.compute.VirtualMachineExtension:
derived_from: cloudify.nodes.Root
properties:
Expand Down
Loading

0 comments on commit 250a2d9

Please sign in to comment.