Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4737cb6
before writing unit tests
Oct 21, 2021
d2def33
update tests. fix style issues
Oct 22, 2021
c2af4c6
first working test
Oct 22, 2021
b688af0
have tests
Oct 26, 2021
6684660
more stuff that has working tests
Oct 26, 2021
b9b2a97
test
Oct 27, 2021
c2d5abc
build rhel step 1
Oct 27, 2021
ae902f7
fix that
Oct 27, 2021
1feb794
update plugin yaml
Oct 28, 2021
8c0b041
fix server path
Oct 28, 2021
814a036
try without paramiko
Nov 1, 2021
193dea8
remove from setup.py
Nov 1, 2021
384ab70
update
Nov 1, 2021
80272b4
setup py
Nov 1, 2021
a761ec7
remove constraints
Nov 1, 2021
ff5874b
testing updates
Nov 3, 2021
423cebe
trust
Nov 3, 2021
0063086
fix test?
Nov 3, 2021
e08e073
fix plugin yaml
Nov 4, 2021
f602503
port_ctx.target
Nov 4, 2021
b2a8806
fix port network prop
Nov 4, 2021
eedf024
fix test
Nov 4, 2021
ed5e878
update expose props
Nov 4, 2021
ad67758
update add network
Nov 4, 2021
1b078e6
use is deployed
Nov 4, 2021
493d348
log info about network
Nov 4, 2021
1914c3f
making expose props work with legacy stuff
Nov 4, 2021
c65fce6
fix flake8
Nov 4, 2021
f5dfe6c
cycle fence mode
Nov 4, 2021
e80cd63
add more logs and more tries
Nov 4, 2021
b7e9fb2
you can pull
Nov 4, 2021
368f57d
fix bad request
Nov 4, 2021
9b15a37
update
Nov 4, 2021
74101e6
handle exception bettter
Nov 4, 2021
3208c4d
all tests should now be OK at least until we revert some testing thin…
Nov 4, 2021
2891051
try to set name
Nov 7, 2021
87c17b2
rebuild
Nov 7, 2021
8a63874
fix that annoying bug
Nov 7, 2021
a7a6faf
a little nitpicky
Nov 7, 2021
4371b47
pushed
Nov 7, 2021
85d5a1a
fix that
Nov 7, 2021
2283ab0
using this
Nov 7, 2021
1d95c18
more fools games
Nov 7, 2021
d7d429b
push
Nov 7, 2021
9019e47
testing
Nov 7, 2021
91ab512
properly assign ip
Nov 8, 2021
67e6a2f
fix fumb mistake
Nov 8, 2021
d8250b8
push stuff
Nov 8, 2021
7b4fd70
update
Nov 9, 2021
23d286d
fix vm
Nov 9, 2021
051cc29
...
Nov 9, 2021
2b3ad79
add deploy false and delete vm improvements
Nov 9, 2021
ec0e516
delete work
Nov 9, 2021
a7ac4bc
try to delete some more
Nov 9, 2021
834bf40
pushed
Nov 9, 2021
a345d76
push vm
Nov 9, 2021
5266e4b
delete vm vapp
Nov 9, 2021
90af778
added fix for failing preconfigure_nic & bumped the version to 2.0.3
Dec 15, 2021
1d3405f
Merge pull request #24 from jrzeszutek/fix-retry-bad-request
EarthmanT Dec 15, 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
Binary file added .DS_Store
Binary file not shown.
13 changes: 7 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ commands:
command: pip install --user tox
- run:
name: Run Flake8
command: /home/circleci/.local/bin/tox -e code_quality
command: /home/circleci/.local/bin/tox -e flake8
- run:
name: Run nosetest
command: /home/circleci/.local/bin/tox -e unit_tests
command: /home/circleci/.local/bin/tox -e pytest

check_py3_compat:
steps:
Expand Down Expand Up @@ -402,10 +402,11 @@ workflows:
- unittests_py36
- validate_version
- validate_documentation
- rhel_wagon:
filters:
branches:
only: /([0-9\.]*\-build|main|dev)/
- rhel_wagon
# - rhel_wagon:
# filters:
# branches:
# only: /([0-9\.]*\-build|main|dev)/
# - wagon:
# filters:
# branches:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
- New version.
2.0.1:
- Attempt to decrease amount of superfluous API requests, however these calls are almost all inside of the client library.
2.0.2:
- Support some legacy types.
2.0.3:
- Fixed issue with RETRY BAD REQUEST in preconfigure_nic
1 change: 0 additions & 1 deletion cloudify_vcd/decorators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

from pyvcloud.vcd.exceptions import (

AccessForbiddenException,
InternalServerException,
EntityNotFoundException,
Expand Down
2 changes: 1 addition & 1 deletion cloudify_vcd/disk_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def detach_disk(_,
disk_config,
disk_ctx.instance.runtime_properties.get('tasks'))
if not vapp_name:
ctx.logger.warn('No vapp was found to detach disk {n}.'.format(
ctx.logger.debug('No vapp was found to detach disk {n}.'.format(
n=disk_id))
last_task = None
else:
Expand Down
13 changes: 13 additions & 0 deletions cloudify_vcd/legacy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) 2020 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Empty file.
257 changes: 257 additions & 0 deletions cloudify_vcd/legacy/compute/tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
# Copyright (c) 2014-21 Cloudify Platform Ltd. All rights reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from copy import deepcopy

from cloudify.exceptions import OperationRetry

from vcd_plugin_sdk.resources.vapp import VCloudVM, VCloudvApp
from cloudify_common_sdk.utils import (
get_ctx_instance,
skip_creative_or_destructive_operation as skip)

from .. import decorators
from ... import vapp_tasks
from ..utils import VM_NIC_REL
from ...utils import (
expose_props,
get_last_task,
find_rels_by_type,
check_if_task_successful)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def create_server(vm_client, ctx, **_):
if not skip(type(vm_client),
vm_client.name,
ctx,
exists=vm_client.exists,
create_operation=True):
vm_kwargs = deepcopy(vm_client.vapp_object.kwargs)
if 'network' in vm_kwargs:
del vm_kwargs['network']
del vm_kwargs['network_adapter_type']
return vapp_tasks._create_vm(
vm_external=False,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_kwargs,
vm_class=VCloudVM,
vm_ctx=ctx)
return vm_client.vm, None


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def configure_server(vm_client, ctx, **_):
resource, result = vapp_tasks._configure_vm(
vm_external=False,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_client.kwargs,
vm_class=VCloudVM,
vm_ctx=ctx)
# operation_name = ctx.operation.name.split('.')[-1]
# expose_props(operation_name,
# resource,
# _ctx=ctx,
# legacy=True)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def power_off_vapp(vm_client, ctx, **_):
if not skip(type(vm_client.vapp_object),
vm_client.vapp_object.name,
ctx,
exists=vm_client.vapp_object.exists,
delete_operation=True):
return vapp_tasks._power_off_vapp(
vapp_ext=False,
vapp_id=vm_client.name,
vapp_client=vm_client.vapp_object.connection,
vapp_vdc=vm_client.vdc_name,
vapp_config=vm_client.kwargs,
vapp_class=VCloudvApp,
__=ctx)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def stop_vapp(vm_client, ctx, **_):
if not skip(type(vm_client.vapp_object),
vm_client.vapp_object.name,
ctx,
exists=vm_client.vapp_object.exists,
delete_operation=True):
return vapp_tasks._stop_vapp(
vapp_ext=False,
vapp_id=vm_client.name,
vapp_client=vm_client.vapp_object.connection,
vapp_vdc=vm_client.vdc_name,
vapp_config=vm_client.kwargs,
vapp_class=VCloudvApp,
__=ctx)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def delete_vapp(vm_client, ctx, **_):
if not skip(type(vm_client.vapp_object),
vm_client.vapp_object.name,
ctx,
exists=vm_client.vapp_object.exists,
delete_operation=True):
return vapp_tasks._delete_vapp(
vapp_ext=False,
vapp_id=vm_client.name,
vapp_client=vm_client.vapp_object.connection,
vapp_vdc=vm_client.vdc_name,
vapp_config=vm_client.kwargs,
vapp_class=VCloudvApp,
__=ctx)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def start_server(vm_client, ctx, **_):
return vapp_tasks._start_vm(
vm_external=False,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_client.kwargs,
vm_class=VCloudVM,
vm_ctx=ctx)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def stop_server(vm_client, ctx, **_):
return vapp_tasks._stop_vm(
vm_external=False,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_client.kwargs,
vm_class=VCloudVM,
vm_ctx=ctx)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def delete_server(vm_client, ctx, **_):
vm_id = vm_client.name
if not vm_id:
vm_id = ctx.node.properties.get('server', {}).get('name')
if not skip(type(vm_client),
vm_id,
exists=vm_client.exists,
delete_operation=True):
return vapp_tasks._delete_vm(
vm_external=False,
vm_id=vm_id,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_client.kwargs,
vm_class=VCloudVM,
vm_ctx=ctx)
return vm_client.vm, None


@decorators.with_port_resource()
def port_creation_validation(*_, **__):
pass


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def preconfigure_nic(vm_client, ctx, server, **kwargs):
for port_ctx in find_rels_by_type(get_ctx_instance(), VM_NIC_REL):
resource, result = vapp_tasks._add_network(
nic_config=port_ctx.target.instance.runtime_properties['port'],
nic_ctx=port_ctx.target,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=server,
vm_class=VCloudVM,
vm_ctx=ctx,
**kwargs)
last_task = get_last_task(result)
if not check_if_task_successful(resource, last_task):
raise OperationRetry('Pending for operation completion.')
operation_name = ctx.operation.name.split('.')[-1]
expose_props(operation_name,
resource,
_ctx=port_ctx.target,
legacy=True)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def postconfigure_nic(vm_client, server, ctx, **kwargs):
vm_id = vm_client.name
if not vm_id:
vm_id = ctx.node.properties.get('server', {}).get('name')
ctx.logger.info('Preconfigure vm client name {}'.format(vm_id))
ctx.logger.info('Preconfigure server {}'.format(server))
for port_ctx in find_rels_by_type(get_ctx_instance(), VM_NIC_REL):
# port = convert_nic_config(
# port_ctx.target.instance.runtime_properties['port'])
resource, result = vapp_tasks._add_nic(
nic_config=port_ctx.target.instance.runtime_properties['port'],
nic_ctx=port_ctx.target,
vm_id=vm_id,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=server,
vm_class=VCloudVM,
vm_ctx=ctx,
**kwargs)
last_task = get_last_task(result)
if not check_if_task_successful(resource, last_task):
raise OperationRetry('Pending for add nic operation completion...')
operation_name = ctx.operation.name.split('.')[-1]
expose_props(operation_name,
resource,
_ctx=port_ctx.target,
legacy=True)


@decorators.with_vcd_client()
@decorators.with_vm_resource()
def unlink_nic(vm_client, ctx, **kwargs):
for port_ctx in find_rels_by_type(get_ctx_instance(), VM_NIC_REL):
resource, result = vapp_tasks._delete_nic(
nic_config=port_ctx.target.instance.runtime_properties['port'],
nic_ctx=port_ctx.target,
vm_id=vm_client.name,
vm_client=vm_client.connection,
vm_vdc=vm_client.vdc_name,
vm_config=vm_client.kwargs,
vm_class=VCloudVM,
vm_ctx=ctx,
**kwargs)
last_task = get_last_task(result)
if not check_if_task_successful(resource, last_task):
raise OperationRetry('Pending for unlink operation completion...')
operation_name = ctx.operation.name.split('.')[-1]
expose_props(operation_name,
resource,
_ctx=port_ctx.target,
legacy=True)
Loading