Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
CloudStack Simulator of 32 host advanced zone + test to deploy 250 vms
{
"zones": [
{
"name": "Sandbox-simulator",
"guestcidraddress": "10.1.0.0/16",
"dns1": "10.147.28.6",
"physical_networks": [
{
"broadcastdomainrange": "Zone",
"vlan": "100-200",
"name": "Sandbox-pnet",
"traffictypes": [
{
"typ": "Guest"
},
{
"typ": "Management"
},
{
"typ": "Public"
}
],
"providers": [
{
"broadcastdomainrange": "ZONE",
"name": "VirtualRouter"
},
{
"broadcastdomainrange": "ZONE",
"name": "VpcVirtualRouter"
},
{
"broadcastdomainrange": "ZONE",
"name": "InternalLbVm"
}
],
"isolationmethods": [
"VLAN"
]
}
],
"ipranges": [
{
"startip": "192.168.1.2",
"endip": "192.168.245.200",
"netmask": "255.255.0.0",
"vlan": "50",
"gateway": "192.168.1.1"
}
],
"networktype": "Advanced",
"pods": [
{
"endip": "172.16.200.254",
"name": "POD0",
"startip": "172.16.1.2",
"netmask": "255.255.0.0",
"gateway": "172.16.1.1",
"clusters": [
{
"clustername": "C0",
"hypervisor": "simulator",
"hosts": [
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
}
],
"clustertype": "CloudManaged",
"primaryStorages": [
{
"url": "nfs://nfsstor:/export/home/sandbox/primary0",
"name": "PS0"
}
]
},
{
"clustername": "C1",
"hypervisor": "simulator",
"hosts": [
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
}
],
"clustertype": "CloudManaged",
"primaryStorages": [
{
"url": "nfs://nfsstor:/export/home/sandbox/primary1",
"name": "PS1"
}
]
},
{
"clustername": "C2",
"hypervisor": "simulator",
"hosts": [
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
}
],
"clustertype": "CloudManaged",
"primaryStorages": [
{
"url": "nfs://nfsstor:/export/home/sandbox/primary2",
"name": "PS2"
}
]
},
{
"clustername": "C3",
"hypervisor": "simulator",
"hosts": [
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
},
{
"username": "root",
"url": "http://sim/c0/h0",
"password": "password"
}
],
"clustertype": "CloudManaged",
"primaryStorages": [
{
"url": "nfs://nfsstor:/export/home/sandbox/primary3",
"name": "PS3"
}
]
}
]
}
],
"internaldns1": "10.147.28.6",
"secondaryStorages": [
{
"url": "nfs://10.147.28.6:/export/home/sandbox/secondary",
"provider" : "NFS"
}
]
}
],
"dbSvr": {
"dbSvr": "localhost",
"passwd": "cloud",
"db": "cloud",
"port": 3306,
"user": "cloud"
},
"logger": [
{
"name": "TestClient",
"file": "/tmp/testclient.log"
},
{
"name": "TestCase",
"file": "/tmp/testcase.log"
}
],
"globalConfig": [
{
"name": "network.gc.wait",
"value": "60"
},
{
"name": "storage.cleanup.interval",
"value": "300"
},
{
"name": "vm.op.wait.interval",
"value": "5"
},
{
"name": "default.page.size",
"value": "10000"
},
{
"name": "network.gc.interval",
"value": "60"
},
{
"name": "instance.name",
"value": "QA"
},
{
"name": "workers",
"value": "10"
},
{
"name": "account.cleanup.interval",
"value": "600"
},
{
"name": "guest.domain.suffix",
"value": "sandbox.simulator"
},
{
"name": "expunge.delay",
"value": "60"
},
{
"name": "vm.allocation.algorithm",
"value": "random"
},
{
"name": "expunge.interval",
"value": "60"
},
{
"name": "expunge.workers",
"value": "3"
},
{
"name": "check.pod.cidrs",
"value": "true"
},
{
"name": "secstorage.allowed.internal.sites",
"value": "10.147.28.0/24"
},
{
"name": "direct.agent.load.size",
"value": "1000"
},
{
"name": "max.account.cpus",
"value": "4000"
},
{
"name": "max.account.memory",
"value": "40960000"
},
{
"name": "max.account.primary.storage",
"value": "200000"
},
{
"name": "max.account.user.vms",
"value": "1000"
},
{
"name": "max.account.volumes",
"value": "2000"
},
{
"name": "cluster.memory.allocated.capacity.disablethreshold",
"value": "1"
}
],
"mgtSvr": [
{
"mgtSvrIp": "localhost",
"passwd": "password",
"user": "root",
"port": 8096,
"hypervisor" : "simulator"
}
]
}
# 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.
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
from marvin.integration.lib.common import get_zone, get_domain, get_template, cleanup_resources
from nose.plugins.attrib import attr
class Services:
def __init__(self):
self.services = {
"account": {
"email": "test@test.com",
"firstname": "Test",
"lastname": "User",
"username": "test",
# Random characters are appended for unique
# username
"password": "password",
},
"service_offering": {
"name": "Planner Service Offering",
"displaytext": "Planner Service Offering",
"cpunumber": 1,
"cpuspeed": 100,
# in MHz
"memory": 1024,
# In MBs
},
"ostype": 'CentOS 5.3 (64-bit)',
"virtual_machine": {
"hypervisor": "XenServer",
}
}
class TestDeployLotsOfVMsWithFirstFitPlanner(cloudstackTestCase):
""" Test to create lots of VMs with first fit deployment planner
- firstfit
"""
@classmethod
def setUpClass(cls):
cls.apiclient = super(TestDeployLotsOfVMsWithFirstFitPlanner, cls).getClsTestClient().getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient, cls.services)
cls.zone = get_zone(cls.apiclient, cls.services)
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.services["account"] = cls.account.name
cls.hosts = Host.list(cls.apiclient, type='Routing')
cls.clusters = Cluster.list(cls.apiclient)
cls.cleanup = [
# cls.account
]
@attr(tags=["simulator", "advanced", "basic", "sg"])
def test_deploylotsofvms_firstfit(self):
"""Test to deploy 250 vms with a first fit offering
"""
self.service_offering_firstfit = ServiceOffering.create(
self.apiclient,
self.services["service_offering"],
deploymentplanner='FirstFitPlanner'
)
i = 0
while (i<250):
self.CreateVM()
i = i + 1
def CreateVM(self):
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
zoneid=self.zone.id,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_firstfit.id,
templateid=self.template.id
)
list_vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
self.debug(
"Verify listVirtualMachines response for virtual machine: %s"\
% virtual_machine.id
)
self.assertEqual(
isinstance(list_vms, list),
True,
"List VM response was not a valid list"
)
self.assertNotEqual(
len(list_vms),
0,
"List VM response was empty"
)
vm = list_vms[0]
self.assertEqual(
vm.state,
"Running",
msg="VM is not in Running state"
)
@classmethod
def tearDownClass(cls):
try:
cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment