Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR]Add migration plan via API #9846

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
Commits
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
53 changes: 53 additions & 0 deletions cfme/tests/v2v/test_rest_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from cfme import test_requirements
from cfme.cloud.provider.openstack import OpenStackProvider
from cfme.fixtures.templates import Templates
from cfme.fixtures.v2v_fixtures import get_vm
from cfme.fixtures.v2v_fixtures import set_conversion_host_api
from cfme.infrastructure.provider.rhevm import RHEVMProvider
from cfme.infrastructure.provider.virtualcenter import VMwareProvider
Expand Down Expand Up @@ -225,3 +227,54 @@ def test_rest_conversion_host_crud(appliance, source_provider, provider, transfo
delay=3,
message="Waiting for conversion host configuration task to be deleted")
assert not conversion_collection.all


@pytest.mark.provider([RHEVMProvider], selector=ONE_PER_VERSION,
required_flags=["v2v"], scope='module')
@pytest.mark.parametrize(
"source_type, dest_type, template_type",
[
["nfs", "iscsi", Templates.RHEL7_MINIMAL]
]
)
def test_rest_plan_create(request, appliance, get_clusters, get_datastores, get_networks,
source_type, dest_type, template_type, source_provider
):
"""
Tests migration plan create via API

Polarion:
assignee: sshveta
casecomponent: V2V
testtype: functional
initialEstimate: 1/8h
startsin: 5.9
tags: V2V
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be indented

"""
transformation_mappings = appliance.rest_api.collections.transformation_mappings.action.create(
name=fauxfactory.gen_alphanumeric(),
description=fauxfactory.gen_alphanumeric(),
state="draft",
transformation_mapping_items=[get_clusters, get_datastores, get_networks])[0]

vm_obj = get_vm(request, appliance, source_provider, Templates.RHEL7_MINIMAL)
vm = appliance.rest_api.collections.vms.get(name=vm_obj.name)

migration_plan = appliance.rest_api.collections.service_templates.action.create(
name=fauxfactory.gen_alphanumeric(),
description=fauxfactory.gen_alphanumeric(),
prov_type="generic_transformation_plan",
config_info={"transformation_mapping_id": transformation_mappings.id,
"pre_service_id": "",
"post_service_id": "",
"actions": [{"vm_id": vm.id,
"post_service": "false",
"pre_service": "false",
}]})[0]

@request.addfinalizer
def _cleanup():
if migration_plan.exists:
migration_plan.action.delete()

assert migration_plan.exists