def test_launchpad_starts_when_vm_pool_has_a_vm_resource(self, proxy, cloud_account, vm_pool_name, mgmt_domain_name, network_pool_name): '''Tests that a launchpad can now start when the vm pool has a vm resource Arguments: proxy - a pytest fixture proxy to RwMcYang cloud_account_name - a pytest fixture for the cloud account name vm_pool_name - a pytest fixture for the VM pool name mgmt_domain_name - a pytest fixture for the management domain name Asserts: Cloud account has available resources VM pool has available resources Cloud account and vm pool agree on available resources Configured resource is reflected as assigned in operational data post assignment Launchpad reaches state 'started' ''' account = proxy.get("/cloud-account/account[name='%s']" % cloud_account.name) cloud_vm_ids = [vm.id for vm in account.resources.vm] assert len(cloud_vm_ids) >= 1 pool = proxy.get("/vm-pool/pool[name='%s']" % vm_pool_name) available_ids = [vm.id for vm in pool.available] assert len(available_ids) >= 1 # Assert not split brain assert set(cloud_vm_ids).difference(set(available_ids)) == set([]) pool_config = RwMcYang.VmPool.from_dict({ 'name':vm_pool_name, 'cloud_account':cloud_account.name, 'assigned':[{'id':available_ids[0]}]}) proxy.replace_config("/vm-pool/pool[name='%s']" % vm_pool_name, pool_config) pool = proxy.get("/vm-pool/pool[name='%s']" % vm_pool_name) assigned_ids = [vm.id for vm in pool.assigned] assert available_ids[0] in assigned_ids # Create NW pool pool_config = RwMcYang.NetworkPool( name=network_pool_name, cloud_account=cloud_account.name, dynamic_scaling=True, ) proxy.create_config('/network-pool/pool', pool_config) pool_config = RwMcYang.MgmtDomainPools_Network(name=network_pool_name) proxy.create_config("/mgmt-domain/domain[name='%s']/pools/network" % mgmt_domain_name, pool_config) proxy.wait_for( "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name, 'started', timeout=400, fail_on=['crashed'])
def test_create_network_pool(self, proxy, cloud_account_name, network_pool_name): '''Configure network pool Asserts : Newly configured network pool has no resources assigned to it ''' pool_config = RwMcYang.NetworkPool(name=network_pool_name, cloud_account=cloud_account_name) proxy.create_config('/network-pool/pool', pool_config) pool = proxy.get("/network-pool/pool[name='%s']" % network_pool_name) assigned_ids = [network.id for network in pool.assigned] assert assigned_ids == [ ] # pool contained resources before any were assigned