mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-10024: Network Migration (#2374)
Handle PR comments Co-Authored-By: Raf Smeets <raf.smeets@nuagenetworks.net> Co-Authored-By: Kris Sterckx <kris.sterckx@nuagenetworks.net>
This commit is contained in:
parent
36f43b5d53
commit
c436bc3ef9
|
|
@ -18,12 +18,14 @@ package org.apache.cloudstack.api.command.admin.network;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
|
|
@ -38,12 +40,18 @@ import com.cloud.offering.NetworkOffering;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
||||
@APICommand(name = "migrateNetwork", description = "moves a network to another physical network", responseObject = NetworkResponse.class, responseView = ResponseView.Restricted, entityType = {Network.class},
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = MigrateNetworkCmd.APINAME, description = "moves a network to another physical network",
|
||||
responseObject = NetworkResponse.class,
|
||||
responseView = ResponseView.Restricted,
|
||||
entityType = {Network.class},
|
||||
requestHasSensitiveInfo = false,
|
||||
responseHasSensitiveInfo = false,
|
||||
since = "4.11.0",
|
||||
authorized = {RoleType.Admin})
|
||||
public class MigrateNetworkCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(MigrateNetworkCmd.class.getName());
|
||||
|
||||
private static final String s_name = "migratenetworkresponse";
|
||||
public static final String APINAME = "migrateNetwork";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
@ -81,7 +89,7 @@ public class MigrateNetworkCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,34 +16,44 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.api.command.admin.network;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.VpcOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.VpcResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.network.vpc.Vpc;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
|
||||
@APICommand(name = "migrateVPC", description = "moves a vpc to another physical network", responseObject = VpcResponse.class, responseView = ResponseObject.ResponseView.Restricted, entityType = {Vpc.class},
|
||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = MigrateVPCCmd.APINAME,
|
||||
description = "moves a vpc to another physical network",
|
||||
responseObject = VpcResponse.class,
|
||||
responseView = ResponseObject.ResponseView.Restricted,
|
||||
entityType = {Vpc.class},
|
||||
requestHasSensitiveInfo = false,
|
||||
responseHasSensitiveInfo = false,
|
||||
since = "4.11.0",
|
||||
authorized = {RoleType.Admin})
|
||||
public class MigrateVPCCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(MigrateVPCCmd.class.getName());
|
||||
|
||||
private static final String s_name = "migratevpcresponse";
|
||||
public static final String APINAME = "migrateVPC";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
@ -86,7 +96,7 @@ public class MigrateVPCCmd extends BaseAsyncCmd {
|
|||
}
|
||||
|
||||
for (HashMap<String, String> map : tierNetworkOfferings.values()) {
|
||||
flatMap.put(map.get("networkid"), map.get("networkofferingid"));
|
||||
flatMap.put(map.get("networkid"), map.get("networkofferingid"));
|
||||
}
|
||||
|
||||
return flatMap;
|
||||
|
|
@ -98,7 +108,7 @@ public class MigrateVPCCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -87,14 +87,6 @@ public final class LibvirtReplugNicCommandWrapper extends CommandWrapper<ReplugN
|
|||
s_logger.debug("ReplugNic: Updating interface" + interfaceDef);
|
||||
vm.updateDeviceFlags(interfaceDef.toString(), DomainAffect.LIVE.getValue());
|
||||
|
||||
/*
|
||||
// Manual replug
|
||||
for (final VifDriver vifDriver : libvirtComputingResource.getAllVifDrivers()) {
|
||||
vifDriver.detach(oldPluggedNic);
|
||||
}
|
||||
newVifDriver.attach(interfaceDef);
|
||||
*/
|
||||
|
||||
// We don't know which "traffic type" is associated with
|
||||
// each interface at this point, so inform all vif drivers
|
||||
for (final VifDriver vifDriver : libvirtComputingResource.getAllVifDrivers()) {
|
||||
|
|
|
|||
|
|
@ -19,13 +19,7 @@
|
|||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.manager.NuageVspManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
|
|
@ -40,11 +34,20 @@ import org.apache.cloudstack.api.response.VpcResponse;
|
|||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.manager.NuageVspManager;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = AssociateNuageVspDomainTemplateCmd.APINAME, responseObject = SuccessResponse.class, description = "associate a vpc with a domain template", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User})
|
||||
@APICommand(name = AssociateNuageVspDomainTemplateCmd.APINAME, responseObject = SuccessResponse.class,
|
||||
description = "associate a vpc with a domain template", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User},
|
||||
since = "4.11.0")
|
||||
public class AssociateNuageVspDomainTemplateCmd extends BaseCmd {
|
||||
static final String APINAME = "associateNuageVspDomainTemplate";
|
||||
|
||||
@Inject
|
||||
NuageVspManager _nuageVspManager;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
|
|||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
@APICommand(name = ListNuageVspDomainTemplatesCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", since = "4.11", responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User})
|
||||
@APICommand(name = ListNuageVspDomainTemplatesCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", since = "4.11.0", responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User})
|
||||
public class ListNuageVspDomainTemplatesCmd extends BaseCmd {
|
||||
static final String APINAME = "listNuageVspDomainTemplates";
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@
|
|||
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
|
|
@ -27,11 +32,6 @@ import org.apache.cloudstack.api.BaseResponse;
|
|||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.api.response.NuageVspDomainTemplateResponse;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -43,7 +43,9 @@ import com.cloud.network.manager.NuageVspManager;
|
|||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = ListNuageVspGlobalDomainTemplateCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User})
|
||||
@APICommand(name = ListNuageVspGlobalDomainTemplateCmd.APINAME, responseObject = BaseResponse.class,
|
||||
description = "Lists Nuage VSP domain templates", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User},
|
||||
since = "4.11.0")
|
||||
public class ListNuageVspGlobalDomainTemplateCmd extends BaseCmd {
|
||||
static final String APINAME = "listNuageVspGlobalDomainTemplate";
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,29 @@ import unittest
|
|||
import re
|
||||
|
||||
|
||||
class Services:
|
||||
"""Test network services
|
||||
"""
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"shared_network_offering": {
|
||||
"name": "MySharedOffering-shared",
|
||||
"displaytext": "MySharedOffering",
|
||||
"guestiptype": "Shared",
|
||||
"supportedservices": "Dhcp,Dns,UserData",
|
||||
"specifyVlan": "True",
|
||||
"specifyIpRanges": "True",
|
||||
"traffictype": "GUEST",
|
||||
"tags": "native",
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VirtualRouter",
|
||||
"Dns": "VirtualRouter",
|
||||
"UserData": "VirtualRouter"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TestNuageMigration(nuageTestCase):
|
||||
"""Test Native to Nuage Migration
|
||||
"""
|
||||
|
|
@ -38,6 +61,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestNuageMigration, cls).setUpClass()
|
||||
cls.services = Services().services
|
||||
|
||||
if not hasattr(cls.vsp_physical_network, "tags") \
|
||||
or cls.vsp_physical_network.tags != 'nuage':
|
||||
|
|
@ -99,7 +123,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
|
||||
# create a Native shared network offering
|
||||
cls.native_shared_network_offering = cls.create_NetworkOffering(
|
||||
cls.test_data["shared_network_offering"], False)
|
||||
cls.services["shared_network_offering"], False)
|
||||
|
||||
# create a Nuage shared network offering
|
||||
cls.nuage_shared_network_offering = cls.create_NetworkOffering(
|
||||
|
|
@ -1217,7 +1241,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating Native VSP VPC offering with Static NAT service "
|
||||
"provider as VPCVR...")
|
||||
native_vpc_off = self.create_VpcOffering(
|
||||
self.test_data["vpc_offering_native"])
|
||||
self.test_data["vpc_offering_reduced"])
|
||||
self.validate_VpcOffering(native_vpc_off, state="Enabled")
|
||||
|
||||
self.debug("Creating a VPC with Static NAT service provider as "
|
||||
|
|
@ -1228,7 +1252,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating native VPC Network Tier offering "
|
||||
"with Static NAT service provider as VPCVR")
|
||||
native_tiernet_off = self.create_NetworkOffering(
|
||||
self.test_data["vpc_network_offering_native"])
|
||||
self.test_data["nw_offering_reduced_vpc"])
|
||||
self.validate_NetworkOffering(native_tiernet_off, state="Enabled")
|
||||
|
||||
acl_list = self.create_NetworkAclList(
|
||||
|
|
@ -1479,7 +1503,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating Native VSP VPC offering with Static NAT service "
|
||||
"provider as VPCVR...")
|
||||
native_vpc_off = self.create_VpcOffering(
|
||||
self.test_data["vpc_offering_native"])
|
||||
self.test_data["vpc_offering_reduced"])
|
||||
self.validate_VpcOffering(native_vpc_off, state="Enabled")
|
||||
|
||||
self.debug("Creating a VPC with Static NAT service provider as "
|
||||
|
|
@ -1490,7 +1514,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating native VPC Network Tier offering "
|
||||
"with Static NAT service provider as VPCVR")
|
||||
native_tiernet_off = self.create_NetworkOffering(
|
||||
self.test_data["vpc_network_offering_native"])
|
||||
self.test_data["nw_offering_reduced_vpc"])
|
||||
self.validate_NetworkOffering(native_tiernet_off, state="Enabled")
|
||||
|
||||
acl_list = self.create_NetworkAclList(
|
||||
|
|
@ -1797,7 +1821,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating Native VSP VPC offering with Static NAT service "
|
||||
"provider as VPCVR...")
|
||||
native_vpc_off = self.create_VpcOffering(
|
||||
self.test_data["vpc_offering_native"])
|
||||
self.test_data["vpc_offering_reduced"])
|
||||
self.validate_VpcOffering(native_vpc_off, state="Enabled")
|
||||
|
||||
self.debug("Creating a VPC with Static NAT service provider as "
|
||||
|
|
@ -1808,7 +1832,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating native VPC Network Tier offering "
|
||||
"with Static NAT service provider as VPCVR")
|
||||
native_tiernet_off = self.create_NetworkOffering(
|
||||
self.test_data["vpc_network_offering_native"])
|
||||
self.test_data["nw_offering_reduced_vpc"])
|
||||
self.validate_NetworkOffering(native_tiernet_off, state="Enabled")
|
||||
|
||||
acl_list = self.create_NetworkAclList(
|
||||
|
|
@ -1917,7 +1941,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating Native VSP VPC offering with Static NAT service "
|
||||
"provider as VPCVR...")
|
||||
native_vpc_off = self.create_VpcOffering(
|
||||
self.test_data["vpc_offering_native"])
|
||||
self.test_data["vpc_offering_reduced"])
|
||||
self.validate_VpcOffering(native_vpc_off, state="Enabled")
|
||||
|
||||
self.debug("Creating a VPC with Static NAT service provider as "
|
||||
|
|
@ -1928,7 +1952,7 @@ class TestNuageMigration(nuageTestCase):
|
|||
self.debug("Creating native VPC Network Tier offering "
|
||||
"with Static NAT service provider as VPCVR")
|
||||
native_tiernet_off = self.create_NetworkOffering(
|
||||
self.test_data["vpc_network_offering_native"])
|
||||
self.test_data["nw_offering_reduced_vpc"])
|
||||
self.validate_NetworkOffering(native_tiernet_off, state="Enabled")
|
||||
|
||||
acl_list = self.create_NetworkAclList(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,333 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you 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.
|
||||
|
||||
""" Network migration test
|
||||
"""
|
||||
# Import Local Modules
|
||||
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
|
||||
from marvin.lib.base import (
|
||||
Account,
|
||||
ServiceOffering,
|
||||
VirtualMachine,
|
||||
NetworkOffering,
|
||||
Network,
|
||||
VpcOffering,
|
||||
VPC
|
||||
)
|
||||
from marvin.lib.common import (get_domain,
|
||||
get_zone,
|
||||
get_template,
|
||||
list_virtual_machines)
|
||||
|
||||
from marvin.lib.utils import (get_hypervisor_type,
|
||||
cleanup_resources)
|
||||
|
||||
|
||||
# Import System Modules
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
|
||||
class Services:
|
||||
"""Test network services
|
||||
"""
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"vpc": {
|
||||
"name": "TestVPC",
|
||||
"displaytext": "TestVPC",
|
||||
"cidr": '10.0.0.1/24'
|
||||
},
|
||||
"network": {
|
||||
"name": "Test Network",
|
||||
"displaytext": "Test Network",
|
||||
"netmask": '255.255.255.0'
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "Test VM",
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
class TestNetworkMigration(cloudstackTestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(TestNetworkMigration, cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
cls.test_data = cls.testClient.getParsedTestDataConfig()
|
||||
cls.services = Services().services
|
||||
|
||||
hypervisor = get_hypervisor_type(cls.api_client)
|
||||
if hypervisor.lower() not in ["vmware", "kvm"]:
|
||||
raise unittest.SkipTest("This feature is supported "
|
||||
"only on Vmware and KVM")
|
||||
|
||||
# Get Domain, Zone, Template
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
cls.zone = get_zone(
|
||||
cls.api_client,
|
||||
cls.testClient.getZoneForTests())
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.test_data["ostype"]
|
||||
)
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
if cls.zone.localstorageenabled:
|
||||
cls.storagetype = 'local'
|
||||
cls.test_data["service_offerings"][
|
||||
"tiny"]["storagetype"] = 'local'
|
||||
else:
|
||||
cls.storagetype = 'shared'
|
||||
cls.test_data["service_offerings"][
|
||||
"tiny"]["storagetype"] = 'shared'
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.test_data["service_offerings"]["tiny"]
|
||||
)
|
||||
|
||||
# Create Network offering without userdata
|
||||
cls.network_offering_nouserdata = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.test_data["network_offering"]
|
||||
)
|
||||
# Enable Network offering
|
||||
cls.network_offering_nouserdata.update(cls.api_client,
|
||||
state='Enabled')
|
||||
|
||||
# Create Network Offering with all the serices
|
||||
cls.network_offering_all = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.test_data["isolated_network_offering"]
|
||||
)
|
||||
# Enable Network offering
|
||||
cls.network_offering_all.update(cls.api_client, state='Enabled')
|
||||
|
||||
cls.native_vpc_network_offering = NetworkOffering.create(
|
||||
cls.api_client,
|
||||
cls.test_data["nw_offering_isolated_vpc"],
|
||||
conservemode=False)
|
||||
cls.native_vpc_network_offering.update(cls.api_client,
|
||||
state='Enabled')
|
||||
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.network_offering_nouserdata,
|
||||
cls.network_offering_all,
|
||||
cls.native_vpc_network_offering
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.hypervisor = self.testClient.getHypervisorInfo()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.test_data["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.account.delete(self.apiclient)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
# Cleanup resources used
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
def migrate_network(self, nw_off, network, resume=False):
|
||||
return network.migrate(self.api_client, nw_off.id, resume)
|
||||
|
||||
def migrate_vpc(self, vpc, vpc_offering,
|
||||
network_offering_map, resume=False):
|
||||
return vpc.migrate(self.api_client,
|
||||
vpc_offering.id,
|
||||
network_offering_map, resume)
|
||||
|
||||
@attr(tags=["advanced", "smoke", "nativeisoonly"],
|
||||
required_hardware="false")
|
||||
def test_01_native_to_native_network_migration(self):
|
||||
"""
|
||||
Verify Migration for an isolated network nativeOnly
|
||||
1. create native non-persistent isolated network
|
||||
2. migrate to other non-persistent isolated network
|
||||
3. migrate back to first native non-persistent network
|
||||
4. deploy VM in non-persistent isolated network
|
||||
5. migrate to native persistent isolated network
|
||||
6. migrate back to native non-persistent network
|
||||
"""
|
||||
|
||||
isolated_network = Network.create(
|
||||
self.apiclient,
|
||||
self.test_data["isolated_network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=self.network_offering_all.id,
|
||||
zoneid=self.zone.id
|
||||
)
|
||||
|
||||
self.migrate_network(
|
||||
self.network_offering_nouserdata,
|
||||
isolated_network, resume=False)
|
||||
|
||||
self.migrate_network(
|
||||
self.network_offering_all,
|
||||
isolated_network, resume=False)
|
||||
|
||||
deployVmResponse = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
services=self.test_data["virtual_machine_userdata"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(isolated_network.id)],
|
||||
templateid=self.template.id,
|
||||
zoneid=self.zone.id
|
||||
)
|
||||
vms = list_virtual_machines(
|
||||
self.apiclient,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
id=deployVmResponse.id
|
||||
)
|
||||
self.assert_(len(vms) > 0, "There are no Vms deployed in the account"
|
||||
" %s" % self.account.name)
|
||||
vm = vms[0]
|
||||
self.assert_(vm.id == str(deployVmResponse.id),
|
||||
"Vm deployed is different from the test")
|
||||
self.assert_(vm.state == "Running", "VM is not in Running state")
|
||||
|
||||
self.migrate_network(
|
||||
self.network_offering_nouserdata,
|
||||
isolated_network, resume=False)
|
||||
|
||||
self.migrate_network(
|
||||
self.network_offering_all,
|
||||
isolated_network, resume=False)
|
||||
|
||||
@attr(tags=["advanced", "smoke", "nativevpconly"],
|
||||
required_hardware="false")
|
||||
def test_02_native_to_native_vpc_migration(self):
|
||||
"""
|
||||
Verify Migration for a vpc network nativeOnly
|
||||
1. create native vpc with 2 tier networks
|
||||
2. migrate to native vpc, check VR state
|
||||
3. deploy VM in vpc tier network
|
||||
4. acquire ip and enable staticnat
|
||||
5. migrate to native vpc network
|
||||
"""
|
||||
|
||||
self.debug("Creating Native VSP VPC offering with Static NAT service "
|
||||
"provider as VPCVR...")
|
||||
native_vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.test_data["vpc_offering_reduced"])
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
native_vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.debug("Creating a VPC with Static NAT service provider as "
|
||||
"VpcVirtualRouter")
|
||||
self.services["vpc"]["cidr"] = '10.1.1.1/16'
|
||||
vpc = VPC.create(
|
||||
self.apiclient,
|
||||
self.services["vpc"],
|
||||
vpcofferingid=native_vpc_off.id,
|
||||
zoneid=self.zone.id,
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
self.debug("Creating native VPC Network Tier offering "
|
||||
"with Static NAT service provider as VPCVR")
|
||||
native_tiernet_off = \
|
||||
NetworkOffering.create(self.apiclient,
|
||||
self.test_data
|
||||
["nw_offering_reduced_vpc"],
|
||||
conservemode=False)
|
||||
native_tiernet_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
self.debug("Creating a VPC tier network with Static NAT service")
|
||||
vpc_tier = Network.create(self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
networkofferingid=native_tiernet_off.id,
|
||||
zoneid=self.zone.id,
|
||||
gateway='10.1.1.1',
|
||||
vpcid=vpc.id if vpc else self.vpc.id
|
||||
)
|
||||
self.debug("Created network with ID: %s" % vpc_tier.id)
|
||||
|
||||
network_offering_map = \
|
||||
[{"networkid": vpc_tier.id,
|
||||
"networkofferingid": self.native_vpc_network_offering.id}]
|
||||
|
||||
self.migrate_vpc(vpc, native_vpc_off,
|
||||
network_offering_map, resume=False)
|
||||
|
||||
network_offering_map = \
|
||||
[{"networkid": vpc_tier.id,
|
||||
"networkofferingid": native_tiernet_off.id}]
|
||||
|
||||
self.migrate_vpc(vpc, native_vpc_off,
|
||||
network_offering_map, resume=False)
|
||||
|
||||
self.debug('Creating VM in network=%s' % native_tiernet_off.name)
|
||||
vm = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.name,
|
||||
domainid=self.account.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(vpc_tier.id)],
|
||||
templateid=self.template.id,
|
||||
zoneid=self.zone.id
|
||||
)
|
||||
self.debug('Created VM=%s in network=%s' %
|
||||
(vm.id, native_tiernet_off.name))
|
||||
|
||||
network_offering_map = \
|
||||
[{"networkid": vpc_tier.id,
|
||||
"networkofferingid": self.native_vpc_network_offering.id}]
|
||||
|
||||
self.migrate_vpc(vpc, native_vpc_off,
|
||||
network_offering_map, resume=False)
|
||||
|
||||
network_offering_map = \
|
||||
[{"networkid": vpc_tier.id,
|
||||
"networkofferingid": native_tiernet_off.id}]
|
||||
|
||||
self.migrate_vpc(vpc, native_vpc_off,
|
||||
network_offering_map, resume=False)
|
||||
|
|
@ -427,8 +427,8 @@ test_data = {
|
|||
"displaytext": "MySharedOffering",
|
||||
"guestiptype": "Shared",
|
||||
"supportedservices": "Dhcp,Dns,UserData",
|
||||
"specifyVlan": "True",
|
||||
"specifyIpRanges": "True",
|
||||
"specifyVlan": "False",
|
||||
"specifyIpRanges": "False",
|
||||
"traffictype": "GUEST",
|
||||
"tags": "native",
|
||||
"serviceProviderList": {
|
||||
|
|
@ -491,6 +491,12 @@ test_data = {
|
|||
"supportedservices":
|
||||
"Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
|
||||
},
|
||||
"vpc_offering_reduced": {
|
||||
"name": "VPC reduced off",
|
||||
"displaytext": "VPC reduced off",
|
||||
"supportedservices":
|
||||
"Dhcp,Dns,SourceNat,UserData,StaticNat,NetworkACL"
|
||||
},
|
||||
"vpc_offering_multi_lb": {
|
||||
"name": "VPC offering with multiple Lb service providers",
|
||||
"displaytext": "VPC offering with multiple Lb service providers",
|
||||
|
|
@ -507,12 +513,6 @@ test_data = {
|
|||
"NetworkACL": 'VpcVirtualRouter'
|
||||
}
|
||||
},
|
||||
"vpc_offering_native": {
|
||||
"name": "VPC native off",
|
||||
"displaytext": "VPC native off",
|
||||
"supportedservices":
|
||||
"Dhcp,Dns,SourceNat,UserData,StaticNat,NetworkACL"
|
||||
},
|
||||
"vpc": {
|
||||
"name": "TestVPC",
|
||||
"displaytext": "TestVPC",
|
||||
|
|
@ -662,6 +662,26 @@ test_data = {
|
|||
"Lb": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_offering_reduced_vpc": {
|
||||
"name": 'Reduced Network for VPC',
|
||||
"displaytext": 'Reduced Network for VPC',
|
||||
"guestiptype": 'Isolated',
|
||||
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,UserData,'
|
||||
'Dns',
|
||||
"traffictype": 'GUEST',
|
||||
"availability": 'Optional',
|
||||
"tags": "native",
|
||||
"useVpc": 'on',
|
||||
"ispersistent": 'True',
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VpcVirtualRouter",
|
||||
"StaticNat": "VpcVirtualRouter",
|
||||
"SourceNat": "VpcVirtualRouter",
|
||||
"NetworkACL": "VpcVirtualRouter",
|
||||
"UserData": "VpcVirtualRouter",
|
||||
"Dns": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"nw_off_persistent_VPCVR_LB": {
|
||||
"name": "Persistent Network VPC with LB",
|
||||
"displaytext": "Persistent Network VPC No LB",
|
||||
|
|
@ -723,25 +743,6 @@ test_data = {
|
|||
"StaticNat": "VirtualRouter"
|
||||
}
|
||||
},
|
||||
"vpc_network_offering_native": {
|
||||
"name": 'vpc_net_off_marvin_native',
|
||||
"displaytext": 'vpc_net_off_marvin_native',
|
||||
"guestiptype": 'Isolated',
|
||||
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,UserData,Dns',
|
||||
"traffictype": 'GUEST',
|
||||
"availability": 'Optional',
|
||||
"tags": "native",
|
||||
"useVpc": 'on',
|
||||
"ispersistent": 'True',
|
||||
"serviceProviderList": {
|
||||
"Dhcp": "VpcVirtualRouter",
|
||||
"StaticNat": "VpcVirtualRouter",
|
||||
"SourceNat": "VpcVirtualRouter",
|
||||
"NetworkACL": "VpcVirtualRouter",
|
||||
"UserData": "VpcVirtualRouter",
|
||||
"Dns": "VpcVirtualRouter"
|
||||
}
|
||||
},
|
||||
"fwrule": {
|
||||
"startport": 22,
|
||||
"endport": 22,
|
||||
|
|
|
|||
Loading…
Reference in New Issue