mirror of https://github.com/apache/cloudstack.git
1. Support for egress rules, Network offerings and High Availability tests
2. Remove uneccesary code in project file.
This commit is contained in:
parent
9b1fd4d414
commit
78616f5695
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,968 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
# Copyright 2012 Citrix Systems, Inc. Licensed under the
|
||||
# Apache License, Version 2.0 (the "License"); you may not use this
|
||||
# file except in compliance with the License. Citrix Systems, Inc.
|
||||
# reserves all rights not expressly granted by 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.
|
||||
#
|
||||
# Automatically generated by addcopyright.py at 04/03/2012
|
||||
|
||||
""" P1 tests for high availability
|
||||
"""
|
||||
#Import Local Modules
|
||||
from cloudstackTestCase import *
|
||||
from cloudstackAPI import *
|
||||
from testcase.libs.utils import *
|
||||
from testcase.libs.base import *
|
||||
from testcase.libs.common import *
|
||||
import remoteSSHClient
|
||||
import datetime
|
||||
|
||||
|
||||
class Services:
|
||||
"""Test network offering Services
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.services = {
|
||||
"account": {
|
||||
"email": "test@test.com",
|
||||
"firstname": "HA",
|
||||
"lastname": "HA",
|
||||
"username": "HA",
|
||||
# Random characters are appended for unique
|
||||
# username
|
||||
"password": "password",
|
||||
},
|
||||
"service_offering": {
|
||||
"name": "Tiny Instance",
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
},
|
||||
"lbrule": {
|
||||
"name": "SSH",
|
||||
"alg": "roundrobin",
|
||||
# Algorithm used for load balancing
|
||||
"privateport": 22,
|
||||
"publicport": 2222,
|
||||
},
|
||||
"natrule": {
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": "TCP"
|
||||
},
|
||||
"fw_rule":{
|
||||
"startport": 1,
|
||||
"endport": 6000,
|
||||
"cidr": '55.55.0.0/11',
|
||||
# Any network (For creating FW rule)
|
||||
},
|
||||
"virtual_machine": {
|
||||
"displayname": "VM",
|
||||
"username": "root",
|
||||
"password": "password",
|
||||
"ssh_port": 22,
|
||||
"hypervisor": 'XenServer',
|
||||
# Hypervisor type should be same as
|
||||
# hypervisor type of cluster
|
||||
"privateport": 22,
|
||||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"ostypeid": '9958b10f-9e5d-4ef1-908d-a047372d823b',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"sleep": 60,
|
||||
"timeout": 100,
|
||||
"mode":'advanced'
|
||||
}
|
||||
|
||||
|
||||
class TestHighAvailability(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
cls.api_client = super(
|
||||
TestHighAvailability,
|
||||
cls
|
||||
).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.domain = get_domain(
|
||||
cls.api_client,
|
||||
cls.services
|
||||
)
|
||||
cls.zone = get_zone(
|
||||
cls.api_client,
|
||||
cls.services
|
||||
)
|
||||
cls.pod = get_pod(
|
||||
cls.api_client,
|
||||
zoneid=cls.zone.id,
|
||||
services=cls.services
|
||||
)
|
||||
cls.template = get_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.services["ostypeid"]
|
||||
)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
cls.services["virtual_machine"]["template"] = cls.template.id
|
||||
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"],
|
||||
offerha=True
|
||||
)
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
]
|
||||
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)
|
||||
# return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.account = Account.create(
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self.cleanup = [self.account]
|
||||
return
|
||||
|
||||
# def tearDown(self):
|
||||
# try:
|
||||
# #Clean up, terminate the created accounts, domains etc
|
||||
# cleanup_resources(self.apiclient, self.cleanup)
|
||||
# self.testClient.close()
|
||||
# except Exception as e:
|
||||
# raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
# return
|
||||
|
||||
def test_01_host_maintenance_mode(self):
|
||||
"""Test host maintenance mode
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Create Vms. Acquire IP. Create port forwarding & load balancing
|
||||
# rules for Vms.
|
||||
# 2. Host 1: put to maintenance mode. All Vms should failover to Host
|
||||
# 2 in cluster. Vms should be in running state. All port forwarding
|
||||
# rules and load balancing Rules should work.
|
||||
# 3. After failover to Host 2 succeeds, deploy Vms. Deploy Vms on host
|
||||
# 2 should succeed.
|
||||
# 4. Host 1: cancel maintenance mode.
|
||||
# 5. Host 2 : put to maintenance mode. All Vms should failover to
|
||||
# Host 1 in cluster.
|
||||
# 6. After failover to Host 1 succeeds, deploy VMs. Deploy Vms on
|
||||
# host 1 should succeed.
|
||||
|
||||
hosts = Host.list(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
resourcestate='Enabled',
|
||||
type='Routing'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(hosts, list),
|
||||
True,
|
||||
"List hosts should return valid host response"
|
||||
)
|
||||
self.assertEqual(
|
||||
len(hosts),
|
||||
2,
|
||||
"There must be two hosts present in a cluster"
|
||||
)
|
||||
self.debug("Checking HA with hosts: %s, %s" % (
|
||||
hosts[0].name,
|
||||
hosts[1].name
|
||||
))
|
||||
self.debug("Deploying VM in account: %s" % self.account.account.name)
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in RUnning state"
|
||||
)
|
||||
networks = Network.list(
|
||||
self.apiclient,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(networks, list),
|
||||
True,
|
||||
"List networks should return valid list for the account"
|
||||
)
|
||||
network = networks[0]
|
||||
|
||||
self.debug("Associating public IP for account: %s" %
|
||||
self.account.account.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.account.name,
|
||||
zoneid=self.zone.id,
|
||||
domainid=self.account.account.domainid,
|
||||
networkid=network.id
|
||||
)
|
||||
|
||||
self.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
self.debug("Creating PF rule for IP address: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
nat_rule= NATRule.create(
|
||||
self.apiclient,
|
||||
virtual_machine,
|
||||
self.services["natrule"],
|
||||
ipaddressid=public_ip.ipaddress.id
|
||||
)
|
||||
|
||||
self.debug("Creating LB rule on IP with NAT: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
|
||||
# Create Load Balancer rule on IP already having NAT rule
|
||||
lb_rule = LoadBalancerRule.create(
|
||||
self.apiclient,
|
||||
self.services["lbrule"],
|
||||
ipaddressid=public_ip.ipaddress.id,
|
||||
accountid=self.account.account.name
|
||||
)
|
||||
self.debug("Created LB rule with ID: %s" % lb_rule.id)
|
||||
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
|
||||
first_host = vm.hostid
|
||||
self.debug("Enabling maintenance mode for host %s" % vm.hostid)
|
||||
cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
|
||||
cmd.id = first_host
|
||||
self.apiclient.prepareHostForMaintenance(cmd)
|
||||
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
|
||||
timeout = self.services["timeout"]
|
||||
# Poll and check state of VM while it migrates from one host to another
|
||||
while True:
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
|
||||
self.debug("VM 1 state: %s" % vm.state)
|
||||
if vm.state in ["Stopping", "Stopped", "Running", "Starting"]:
|
||||
if vm.state == "Running":
|
||||
break
|
||||
else:
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = timeout - 1
|
||||
else:
|
||||
self.fail(
|
||||
"VM migration from one-host-to-other failed while enabling maintenance"
|
||||
)
|
||||
second_host = vm.hostid
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"VM should be in Running state after enabling host maintenance"
|
||||
)
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
self.debug("Deploying VM in account: %s" % self.account.account.name)
|
||||
# Spawn an instance on other host
|
||||
virtual_machine_2 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine_2.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.debug("VM 2 state: %s" % vm.state)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
|
||||
self.debug("Canceling host maintenance for ID: %s" % first_host)
|
||||
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
|
||||
cmd.id = first_host
|
||||
self.apiclient.cancelHostMaintenance(cmd)
|
||||
self.debug("Maintenance mode canceled for host: %s" % first_host)
|
||||
|
||||
self.debug("Enabling maintenance mode for host %s" % second_host)
|
||||
cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
|
||||
cmd.id = second_host
|
||||
self.apiclient.prepareHostForMaintenance(cmd)
|
||||
self.debug("Maintenance mode enabled for host: %s" % second_host)
|
||||
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
|
||||
# Poll and check the status of VMs
|
||||
timeout = self.services["timeout"]
|
||||
while True:
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug(
|
||||
"VM state after enabling maintenance on first host: %s" %
|
||||
vm.state)
|
||||
if vm.state in ["Stopping", "Stopped", "Running", "Starting"]:
|
||||
if vm.state == "Running":
|
||||
break
|
||||
else:
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = timeout - 1
|
||||
else:
|
||||
self.fail(
|
||||
"VM migration from one-host-to-other failed while enabling maintenance"
|
||||
)
|
||||
|
||||
for vm in vms:
|
||||
self.debug(
|
||||
"VM states after enabling maintenance mode on host: %s - %s" %
|
||||
(first_host, vm.state))
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
# Spawn an instance on other host
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine_3.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.debug("VM 3 state: %s" % vm.state)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
|
||||
self.debug("Canceling host maintenance for ID: %s" % second_host)
|
||||
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
|
||||
cmd.id = second_host
|
||||
self.apiclient.cancelHostMaintenance(cmd)
|
||||
self.debug("Maintenance mode canceled for host: %s" % second_host)
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
return
|
||||
|
||||
def test_02_host_maintenance_mode_with_activities(self):
|
||||
"""Test host maintenance mode with activities
|
||||
"""
|
||||
|
||||
# Validate the following
|
||||
# 1. Create Vms. Acquire IP. Create port forwarding & load balancing
|
||||
# rules for Vms.
|
||||
# 2. While activities are ongoing: Create snapshots, recurring
|
||||
# snapshots, create templates, download volumes, Host 1: put to
|
||||
# maintenance mode. All Vms should failover to Host 2 in cluster
|
||||
# Vms should be in running state. All port forwarding rules and
|
||||
# load balancing Rules should work.
|
||||
# 3. After failover to Host 2 succeeds, deploy Vms. Deploy Vms on host
|
||||
# 2 should succeed. All ongoing activities in step 3 should succeed
|
||||
# 4. Host 1: cancel maintenance mode.
|
||||
# 5. While activities are ongoing: Create snapshots, recurring
|
||||
# snapshots, create templates, download volumes, Host 2: put to
|
||||
# maintenance mode. All Vms should failover to Host 1 in cluster.
|
||||
# 6. After failover to Host 1 succeeds, deploy VMs. Deploy Vms on
|
||||
# host 1 should succeed. All ongoing activities in step 6 should
|
||||
# succeed.
|
||||
|
||||
hosts = Host.list(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
resourcestate='Enabled',
|
||||
type='Routing'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(hosts, list),
|
||||
True,
|
||||
"List hosts should return valid host response"
|
||||
)
|
||||
self.assertEqual(
|
||||
len(hosts),
|
||||
2,
|
||||
"There must be two hosts present in a cluster"
|
||||
)
|
||||
self.debug("Checking HA with hosts: %s, %s" % (
|
||||
hosts[0].name,
|
||||
hosts[1].name
|
||||
))
|
||||
self.debug("Deploying VM in account: %s" % self.account.account.name)
|
||||
# Spawn an instance in that network
|
||||
virtual_machine = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in RUnning state"
|
||||
)
|
||||
networks = Network.list(
|
||||
self.apiclient,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(networks, list),
|
||||
True,
|
||||
"List networks should return valid list for the account"
|
||||
)
|
||||
network = networks[0]
|
||||
|
||||
self.debug("Associating public IP for account: %s" %
|
||||
self.account.account.name)
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account.account.name,
|
||||
zoneid=self.zone.id,
|
||||
domainid=self.account.account.domainid,
|
||||
networkid=network.id
|
||||
)
|
||||
|
||||
self.debug("Associated %s with network %s" % (
|
||||
public_ip.ipaddress.ipaddress,
|
||||
network.id
|
||||
))
|
||||
self.debug("Creating PF rule for IP address: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
nat_rule= NATRule.create(
|
||||
self.apiclient,
|
||||
virtual_machine,
|
||||
self.services["natrule"],
|
||||
ipaddressid=public_ip.ipaddress.id
|
||||
)
|
||||
|
||||
self.debug("Creating LB rule on IP with NAT: %s" %
|
||||
public_ip.ipaddress.ipaddress)
|
||||
|
||||
# Create Load Balancer rule on IP already having NAT rule
|
||||
lb_rule = LoadBalancerRule.create(
|
||||
self.apiclient,
|
||||
self.services["lbrule"],
|
||||
ipaddressid=public_ip.ipaddress.id,
|
||||
accountid=self.account.account.name
|
||||
)
|
||||
self.debug("Created LB rule with ID: %s" % lb_rule.id)
|
||||
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
# Get the Root disk of VM
|
||||
volumes = list_volumes(
|
||||
self.apiclient,
|
||||
virtualmachineid=virtual_machine.id,
|
||||
type='ROOT',
|
||||
listall=True
|
||||
)
|
||||
volume = volumes[0]
|
||||
self.debug(
|
||||
"Root volume of VM(%s): %s" % (
|
||||
virtual_machine.name,
|
||||
volume.name
|
||||
))
|
||||
# Create a snapshot from the ROOTDISK
|
||||
self.debug("Creating snapshot on ROOT volume: %s" % volume.name)
|
||||
snapshot = Snapshot.create(self.apiclient, volumes[0].id)
|
||||
self.debug("Snapshot created: ID - %s" % snapshot.id)
|
||||
|
||||
snapshots = list_snapshots(
|
||||
self.apiclient,
|
||||
id=snapshot.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(snapshots, list),
|
||||
True,
|
||||
"Check list response returns a valid list"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
snapshots,
|
||||
None,
|
||||
"Check if result exists in list snapshots call"
|
||||
)
|
||||
self.assertEqual(
|
||||
snapshots[0].id,
|
||||
snapshot.id,
|
||||
"Check snapshot id in list resources call"
|
||||
)
|
||||
# Generate template from the snapshot
|
||||
self.debug("Generating template from snapshot: %s" % snapshot.name)
|
||||
template = Template.create_from_snapshot(
|
||||
self.apiclient,
|
||||
snapshot,
|
||||
self.services["templates"]
|
||||
)
|
||||
self.cleanup.append(template)
|
||||
self.debug("Created template from snapshot: %s" % template.id)
|
||||
|
||||
templates = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["templates"]["templatefilter"],
|
||||
id=template.id
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(templates, list),
|
||||
True,
|
||||
"List template call should return the newly created template"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
templates[0].isready,
|
||||
True,
|
||||
"The newly created template should be in ready state"
|
||||
)
|
||||
|
||||
first_host = vm.hostid
|
||||
self.debug("Enabling maintenance mode for host %s" % vm.hostid)
|
||||
cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
|
||||
cmd.id = first_host
|
||||
self.apiclient.prepareHostForMaintenance(cmd)
|
||||
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
|
||||
timeout = self.services["timeout"]
|
||||
# Poll and check state of VM while it migrates from one host to another
|
||||
while True:
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
|
||||
self.debug("VM 1 state: %s" % vm.state)
|
||||
if vm.state in ["Stopping", "Stopped", "Running", "Starting"]:
|
||||
if vm.state == "Running":
|
||||
break
|
||||
else:
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = timeout - 1
|
||||
else:
|
||||
self.fail(
|
||||
"VM migration from one-host-to-other failed while enabling maintenance"
|
||||
)
|
||||
second_host = vm.hostid
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"VM should be in Running state after enabling host maintenance"
|
||||
)
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
self.debug("Deploying VM in account: %s" % self.account.account.name)
|
||||
# Spawn an instance on other host
|
||||
virtual_machine_2 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine_2.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.debug("VM 2 state: %s" % vm.state)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
|
||||
self.debug("Canceling host maintenance for ID: %s" % first_host)
|
||||
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
|
||||
cmd.id = first_host
|
||||
self.apiclient.cancelHostMaintenance(cmd)
|
||||
self.debug("Maintenance mode canceled for host: %s" % first_host)
|
||||
|
||||
# Get the Root disk of VM
|
||||
volumes = list_volumes(
|
||||
self.apiclient,
|
||||
virtualmachineid=virtual_machine_2.id,
|
||||
type='ROOT',
|
||||
listall=True
|
||||
)
|
||||
volume = volumes[0]
|
||||
self.debug(
|
||||
"Root volume of VM(%s): %s" % (
|
||||
virtual_machine_2.name,
|
||||
volume.name
|
||||
))
|
||||
# Create a snapshot from the ROOTDISK
|
||||
self.debug("Creating snapshot on ROOT volume: %s" % volume.name)
|
||||
snapshot = Snapshot.create(self.apiclient, volumes[0].id)
|
||||
self.debug("Snapshot created: ID - %s" % snapshot.id)
|
||||
|
||||
snapshots = list_snapshots(
|
||||
self.apiclient,
|
||||
id=snapshot.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(snapshots, list),
|
||||
True,
|
||||
"Check list response returns a valid list"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
snapshots,
|
||||
None,
|
||||
"Check if result exists in list snapshots call"
|
||||
)
|
||||
self.assertEqual(
|
||||
snapshots[0].id,
|
||||
snapshot.id,
|
||||
"Check snapshot id in list resources call"
|
||||
)
|
||||
# Generate template from the snapshot
|
||||
self.debug("Generating template from snapshot: %s" % snapshot.name)
|
||||
template = Template.create_from_snapshot(
|
||||
self.apiclient,
|
||||
snapshot,
|
||||
self.services["templates"]
|
||||
)
|
||||
self.cleanup.append(template)
|
||||
self.debug("Created template from snapshot: %s" % template.id)
|
||||
|
||||
templates = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter=\
|
||||
self.services["templates"]["templatefilter"],
|
||||
id=template.id
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(templates, list),
|
||||
True,
|
||||
"List template call should return the newly created template"
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
templates[0].isready,
|
||||
True,
|
||||
"The newly created template should be in ready state"
|
||||
)
|
||||
|
||||
self.debug("Enabling maintenance mode for host %s" % second_host)
|
||||
cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
|
||||
cmd.id = second_host
|
||||
self.apiclient.prepareHostForMaintenance(cmd)
|
||||
self.debug("Maintenance mode enabled for host: %s" % second_host)
|
||||
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
|
||||
# Poll and check the status of VMs
|
||||
timeout = self.services["timeout"]
|
||||
while True:
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
account=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
self.debug(
|
||||
"VM state after enabling maintenance on first host: %s" %
|
||||
vm.state)
|
||||
if vm.state in ["Stopping", "Stopped", "Running", "Starting"]:
|
||||
if vm.state == "Running":
|
||||
break
|
||||
else:
|
||||
time.sleep(self.services["sleep"])
|
||||
timeout = timeout - 1
|
||||
else:
|
||||
self.fail(
|
||||
"VM migration from one-host-to-other failed while enabling maintenance"
|
||||
)
|
||||
|
||||
for vm in vms:
|
||||
self.debug(
|
||||
"VM states after enabling maintenance mode on host: %s - %s" %
|
||||
(first_host, vm.state))
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
# Spawn an instance on other host
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account.account.name,
|
||||
domainid=self.account.account.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.apiclient,
|
||||
id=virtual_machine_3.id,
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(vms, list),
|
||||
True,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
self.assertNotEqual(
|
||||
len(vms),
|
||||
0,
|
||||
"List VMs should return valid response for deployed VM"
|
||||
)
|
||||
vm = vms[0]
|
||||
|
||||
self.debug("Deployed VM on host: %s" % vm.hostid)
|
||||
self.debug("VM 3 state: %s" % vm.state)
|
||||
self.assertEqual(
|
||||
vm.state,
|
||||
"Running",
|
||||
"Deployed VM should be in Running state"
|
||||
)
|
||||
|
||||
# Should be able to SSH VM
|
||||
try:
|
||||
self.debug("SSH into VM: %s" % virtual_machine.id)
|
||||
ssh = virtual_machine.get_ssh_client(
|
||||
ipaddress=public_ip.ipaddress.ipaddress)
|
||||
except Exception as e:
|
||||
self.fail("SSH Access failed for %s: %s" % \
|
||||
(virtual_machine.ipaddress, e)
|
||||
)
|
||||
|
||||
self.debug("Canceling host maintenance for ID: %s" % second_host)
|
||||
cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
|
||||
cmd.id = second_host
|
||||
self.apiclient.cancelHostMaintenance(cmd)
|
||||
self.debug("Maintenance mode canceled for host: %s" % second_host)
|
||||
self.debug("Waiting for SSVMs to come up")
|
||||
wait_for_ssvms(
|
||||
self.apiclient,
|
||||
zoneid=self.zone.id,
|
||||
podid=self.pod.id,
|
||||
)
|
||||
return
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -9,7 +9,7 @@
|
|||
# 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.
|
||||
#
|
||||
#
|
||||
# Automatically generated by addcopyright.py at 04/03/2012
|
||||
""" P1 tests for Project
|
||||
"""
|
||||
|
|
@ -40,7 +40,7 @@ class Services:
|
|||
"ipaddress": '192.168.100.21',
|
||||
"username": 'root',
|
||||
"password": 'fr3sca',
|
||||
"port": 22,
|
||||
"port": 22,
|
||||
},
|
||||
"account": {
|
||||
"email": "administrator@clogeny.com",
|
||||
|
|
@ -52,7 +52,7 @@ class Services:
|
|||
"password": "fr3sca",
|
||||
},
|
||||
"user": {
|
||||
"email": "mayur.dhande@clogeny.com",
|
||||
"email": "administrator@clogeny.com",
|
||||
"firstname": "User",
|
||||
"lastname": "User",
|
||||
"username": "User",
|
||||
|
|
@ -118,7 +118,7 @@ class TestUserProjectCreation(cloudstackTestCase):
|
|||
cls.services = Services().services
|
||||
# Get Zone
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
||||
|
||||
# Create domains, account etc.
|
||||
cls.domain = Domain.create(
|
||||
cls.api_client,
|
||||
|
|
@ -131,14 +131,14 @@ class TestUserProjectCreation(cloudstackTestCase):
|
|||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
|
||||
cls.user = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
|
||||
|
||||
cls._cleanup = [cls.account, cls.user, cls.domain]
|
||||
return
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ class TestUserProjectCreation(cloudstackTestCase):
|
|||
# 1. Check if 'allow.user.create.projects' configuration is true
|
||||
# 2. Create a Project as domain admin
|
||||
# 3. Create a Project as domain user
|
||||
# 4. In both 2 and 3 project creation should be successful
|
||||
# 4. In both 2 and 3 project creation should be successful
|
||||
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
|
|
|
|||
|
|
@ -447,7 +447,7 @@ class TestResourceLimitsProject(cloudstackTestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.api_client = super(TestResourceLimitsDomain, cls).getClsTestClient().getApiClient()
|
||||
cls.api_client = super(TestResourceLimitsProject, cls).getClsTestClient().getApiClient()
|
||||
cls.services = Services().services
|
||||
# Get Zone, Domain and templates
|
||||
cls.zone = get_zone(cls.api_client, cls.services)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class Services:
|
|||
"publicport": 22,
|
||||
"protocol": 'TCP',
|
||||
},
|
||||
"ostypeid": '5776c0d2-f331-42db-ba3a-29f1f8319bc9',
|
||||
"ostypeid": '8531d1df-faac-4895-a741-238d3b10e6e6',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"sleep": 60,
|
||||
"timeout": 10,
|
||||
|
|
@ -164,6 +164,23 @@ class TestMultipleProjectCreation(cloudstackTestCase):
|
|||
# 2. add one account to multiple project. Verify at step 2 an account
|
||||
# is allowed to added to multiple project
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project_1 = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -181,7 +198,6 @@ class TestMultipleProjectCreation(cloudstackTestCase):
|
|||
id=project_1.id,
|
||||
listall=True
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
isinstance(list_projects_reponse, list),
|
||||
True,
|
||||
|
|
@ -369,6 +385,23 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
|
|||
# 2. Add different domain account to the project. Add account should
|
||||
# fail
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -479,6 +512,23 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
|
|||
# 2. Delete account who is owner of the project. Delete account should
|
||||
# fail
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -582,6 +632,23 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
|
|||
# 2. Delete domain forcefully. Verify that project is also deleted as
|
||||
# as part of domain cleanup
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -718,6 +785,23 @@ class TestProjectOwners(cloudstackTestCase):
|
|||
# owner. verify new user is project owner and old account is
|
||||
# regular user of the project.
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -859,6 +943,23 @@ class TestProjectOwners(cloudstackTestCase):
|
|||
# owner.
|
||||
# 3. Update project to add another account as an owner
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1140,6 +1241,23 @@ class TestProjectResources(cloudstackTestCase):
|
|||
# 3. Delete the account. Verify resources are still there after
|
||||
# account deletion.
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1256,6 +1374,23 @@ class TestProjectResources(cloudstackTestCase):
|
|||
# account deletion.
|
||||
# 4. Verify all accounts are unassigned from project.
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
|
|
@ -1460,6 +1595,23 @@ class TestProjectSuspendActivate(cloudstackTestCase):
|
|||
# 3. Delete the account. Verify resources are still there after
|
||||
# account deletion.
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
self.debug("Adding %s user to project: %s" % (
|
||||
self.user.account.name,
|
||||
self.project.name
|
||||
|
|
@ -1594,6 +1746,23 @@ class TestProjectSuspendActivate(cloudstackTestCase):
|
|||
# 1. Activate the project
|
||||
# 2. Verify project is activated and we are able to add resources
|
||||
|
||||
# Verify 'project.invite.required' is set to false
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
name='project.invite.required'
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(configs, list),
|
||||
True,
|
||||
"Check for a valid list configurations response"
|
||||
)
|
||||
config = configs[0]
|
||||
self.assertEqual(
|
||||
(config.value).lower(),
|
||||
'false',
|
||||
"'project.invite.required' should be set to false"
|
||||
)
|
||||
|
||||
# Activating the project
|
||||
self.debug("Activating project: %s" % self.project.name)
|
||||
self.project.activate(self.apiclient)
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ class ServiceOffering:
|
|||
self.__dict__.update(items)
|
||||
|
||||
@classmethod
|
||||
def create(cls, apiclient, services, domainid=None):
|
||||
def create(cls, apiclient, services, domainid=None, **kwargs):
|
||||
"""Create Service offering"""
|
||||
cmd = createServiceOffering.createServiceOfferingCmd()
|
||||
cmd.cpunumber = services["cpunumber"]
|
||||
|
|
@ -891,6 +891,7 @@ class ServiceOffering:
|
|||
if domainid:
|
||||
cmd.domainid = domainid
|
||||
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return ServiceOffering(apiclient.createServiceOffering(cmd).__dict__)
|
||||
|
||||
def delete(self, apiclient):
|
||||
|
|
@ -953,12 +954,12 @@ class NetworkOffering:
|
|||
self.__dict__.update(items)
|
||||
|
||||
@classmethod
|
||||
def create(cls, apiclient, services, serviceProviderList=None, **kwargs):
|
||||
def create(cls, apiclient, services, **kwargs):
|
||||
"""Create network offering"""
|
||||
|
||||
cmd = createNetworkOffering.createNetworkOfferingCmd()
|
||||
cmd.displaytext = services["displaytext"]
|
||||
cmd.name = services["name"]
|
||||
cmd.displaytext = "-".join([services["displaytext"], random_gen()])
|
||||
cmd.name = "-".join([services["name"], random_gen()])
|
||||
cmd.guestiptype = services["guestiptype"]
|
||||
cmd.supportedservices = services["supportedservices"]
|
||||
cmd.traffictype = services["traffictype"]
|
||||
|
|
@ -1039,7 +1040,7 @@ class LoadBalancerRule:
|
|||
|
||||
@classmethod
|
||||
def create(cls, apiclient, services, ipaddressid, accountid=None,
|
||||
projectid=None):
|
||||
networkid=None, projectid=None):
|
||||
"""Create Load balancing Rule"""
|
||||
|
||||
cmd = createLoadBalancerRule.createLoadBalancerRuleCmd()
|
||||
|
|
@ -1055,9 +1056,14 @@ class LoadBalancerRule:
|
|||
cmd.privateport = services["privateport"]
|
||||
cmd.publicport = services["publicport"]
|
||||
|
||||
if "openfirewall" in services:
|
||||
cmd.openfirewall = services["openfirewall"]
|
||||
|
||||
if projectid:
|
||||
cmd.projectid = projectid
|
||||
|
||||
|
||||
if networkid:
|
||||
cmd.networkid = networkid
|
||||
return LoadBalancerRule(apiclient.createLoadBalancerRule(cmd).__dict__)
|
||||
|
||||
def delete(self, apiclient):
|
||||
|
|
@ -1322,6 +1328,14 @@ class Network:
|
|||
cmd.id = self.id
|
||||
apiclient.deleteNetwork(cmd)
|
||||
|
||||
def update(self, apiclient, **kwargs):
|
||||
"""Updates network with parameters passed"""
|
||||
|
||||
cmd = updateNetwork.updateNetworkCmd()
|
||||
cmd.id = self.id
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.updateNetwork(cmd))
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all Networks matching criteria"""
|
||||
|
|
@ -1358,6 +1372,14 @@ class Vpn:
|
|||
cmd.publicipid = self.publicipid
|
||||
apiclient.deleteRemoteAccessVpn(cmd)
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all VPN matching criteria"""
|
||||
|
||||
cmd = listRemoteAccessVpns.listRemoteAccessVpnsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listRemoteAccessVpns(cmd))
|
||||
|
||||
|
||||
class VpnUser:
|
||||
"""Manage VPN user"""
|
||||
|
|
@ -1390,6 +1412,14 @@ class VpnUser:
|
|||
cmd.domainid = self.domainid
|
||||
apiclient.removeVpnUser(cmd)
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""List all VPN Users matching criteria"""
|
||||
|
||||
cmd = listVpnUsers.listVpnUsersCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listVpnUsers(cmd))
|
||||
|
||||
|
||||
class Zone:
|
||||
"""Manage Zone"""
|
||||
|
|
@ -1640,7 +1670,48 @@ class SecurityGroup:
|
|||
cmd=revokeSecurityGroupIngress.revokeSecurityGroupIngressCmd()
|
||||
cmd.id=id
|
||||
return apiclient.revokeSecurityGroupIngress(cmd)
|
||||
|
||||
def authorizeEgress(self, apiclient, services, account=None, domainid=None,
|
||||
projectid=None, user_secgrp_list = {}):
|
||||
"""Authorize Egress Rule"""
|
||||
|
||||
cmd=authorizeSecurityGroupEgress.authorizeSecurityGroupEgressCmd()
|
||||
|
||||
if domainid:
|
||||
cmd.domainid = domainid
|
||||
if account:
|
||||
cmd.account = account
|
||||
|
||||
if projectid:
|
||||
cmd.projectid = projectid
|
||||
cmd.securitygroupid=self.id
|
||||
cmd.protocol=services["protocol"]
|
||||
|
||||
if services["protocol"] == 'ICMP':
|
||||
cmd.icmptype = -1
|
||||
cmd.icmpcode = -1
|
||||
else:
|
||||
cmd.startport = services["startport"]
|
||||
cmd.endport = services["endport"]
|
||||
|
||||
cmd.cidrlist = services["cidrlist"]
|
||||
|
||||
cmd.usersecuritygrouplist = []
|
||||
for account, group in user_secgrp_list.items():
|
||||
cmd.usersecuritygrouplist.append({
|
||||
'account' : account,
|
||||
'group': group
|
||||
})
|
||||
|
||||
return (apiclient.authorizeSecurityGroupEgress(cmd).__dict__)
|
||||
|
||||
def revokeEgress(self, apiclient, id):
|
||||
"""Revoke Egress rule"""
|
||||
|
||||
cmd=revokeSecurityGroupEgress.revokeSecurityGroupEgressCmd()
|
||||
cmd.id=id
|
||||
return apiclient.revokeSecurityGroupEgress(cmd)
|
||||
|
||||
@classmethod
|
||||
def list(cls, apiclient, **kwargs):
|
||||
"""Lists all security groups."""
|
||||
|
|
@ -1787,4 +1858,4 @@ class Configurations:
|
|||
|
||||
cmd = listConfigurations.listConfigurationsCmd()
|
||||
[setattr(cmd, k, v) for k, v in kwargs.items()]
|
||||
return(apiclient.listConfigurations(cmd))
|
||||
return(apiclient.listConfigurations(cmd))
|
||||
|
|
|
|||
Loading…
Reference in New Issue