def test_restart_launchpad(self, mc_proxy, mgmt_domain_name,
                               launchpad_session, launchpad_scraper):
        mc_proxy.wait_for("/mgmt-domain/domain[name='%s']/launchpad/state" %
                          mgmt_domain_name,
                          'started',
                          timeout=10,
                          fail_on=['crashed'])

        stop_launchpad_input = RwMcYang.StopLaunchpadInput(
            mgmt_domain=mgmt_domain_name)
        stop_launchpad_output = mc_proxy.rpc(stop_launchpad_input)

        mc_proxy.wait_for("/mgmt-domain/domain[name='%s']/launchpad/state" %
                          mgmt_domain_name,
                          'stopped',
                          timeout=60,
                          fail_on=['crashed'])

        start_launchpad_input = RwMcYang.StartLaunchpadInput(
            mgmt_domain=mgmt_domain_name)
        start_launchpad_output = mc_proxy.rpc(start_launchpad_input)
        mc_proxy.wait_for("/mgmt-domain/domain[name='%s']/launchpad/state" %
                          mgmt_domain_name,
                          'started',
                          timeout=200,
                          fail_on=['crashed'])

        rift.vcs.vcs.wait_until_system_started(launchpad_session)
        launchpad_scraper.reset()
Esempio n. 2
0
    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'])
Esempio n. 3
0
    def test_create_vm_pool_with_bogus_cloud_name(self, proxy,
                                                  secondary_vm_pool_name):
        '''Tests that a vm pool cannot be created if the cloud name is None

        Arguments:
            proxy          - a pytest fixture proxy to RwMcYang
            secondary_vm_pool_name - a pytest fixture for the secondary vm pool name

        Asserts:
            Secondary vm pool name exists
            Secondary vm pool does not exist
            Cloud account does not exist for the bogus cloud account name
            rift.auto.proxy.ProxyRequestError is raised

        '''
        assert secondary_vm_pool_name is not None
        assert proxy.get(
            "/vm-pool/pool[name='%s']" % secondary_vm_pool_name) is None

        bogus_cloud_account_name = 'bogus-cloud-account-name'
        cloud_account = proxy.get("/cloud-account/account[name='%s']" %
                                  bogus_cloud_account_name)
        assert cloud_account is None

        pool_config = RwMcYang.VmPool(
            name=secondary_vm_pool_name,
            cloud_account=bogus_cloud_account_name,
            dynamic_scaling=True,
        )
        with pytest.raises(ProxyRequestError):
            proxy.create_config('/vm-pool/pool', pool_config)
Esempio n. 4
0
    def test_create_vm_pool_with_blank_cloud_name(self, proxy,
                                                  secondary_vm_pool_name):
        '''Tests that a vm pool cannot be created with a name that already exists

        Arguments:
            proxy                  - a pytest fixture proxy to RwMcYang
            secondary_vm_pool_name - a pytest fixture for the secondary vm pool name

        Asserts:
            Secondary vm pool name exists
            Secondary vm pool does not exist
            rift.auto.proxy.ProxyRequestError is raised

        '''
        assert secondary_vm_pool_name is not None
        assert proxy.get(
            "/vm-pool/pool[name='%s']" % secondary_vm_pool_name) is None

        pool_config = RwMcYang.VmPool(
            name=secondary_vm_pool_name,
            cloud_account='',
            dynamic_scaling=True,
        )
        with pytest.raises(ProxyRequestError):
            proxy.create_config('/vm-pool/pool', pool_config)
Esempio n. 5
0
    def test_create_vm_pool_with_duplicate_name(self, proxy, vm_pool_name,
                                                cloud_account):
        '''Tests that a vm pool cannot be created with a name that already exists

        Arguments:
            proxy         - a pytest fixture proxy to RwMcYang
            vm_pool_name  - a pytest fixture for the vm pool name
            cloud_account - a pytest fixture for the cloud account

        Asserts:
            Cloud account has a name
            rift.auto.proxy.ProxyRequestError is raised

        '''
        xpath = "/cloud-account/account[name='%s']" % cloud_account.name
        cloud_account = proxy.get(xpath)
        assert cloud_account.name is not None

        pool_config = RwMcYang.VmPool(
            name=vm_pool_name,
            cloud_account=cloud_account.name,
            dynamic_scaling=True,
        )
        with pytest.raises(ProxyRequestError):
            proxy.create_config('/vm-pool/pool', pool_config)
Esempio n. 6
0
 def test_create_odl_sdn_account(self, proxy, sdn_account_name,
                                 sdn_account_type):
     '''Configure sdn account'''
     sdn_account = RwMcYang.SDNAccount(name=sdn_account_name,
                                       account_type=sdn_account_type)
     xpath = "/sdn/account[name='%s']" % sdn_account_name
     proxy.create_config(xpath, sdn_account)
Esempio n. 7
0
    def test_create_vm_pool(self, proxy, cloud_account, vm_pool_name):
        '''Configure vm pool

        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

        Asserts:
            A cloud account exists for the cloud_account_name
            Newly configured vm pool has no resources assigned to it

        '''
        xpath = "/cloud-account/account[name='%s']" % cloud_account.name
        cloud_account = proxy.get(xpath)
        assert cloud_account is not None

        pool_config = RwMcYang.VmPool(
                name=vm_pool_name,
                cloud_account=cloud_account.name,
                dynamic_scaling=True,
        )
        proxy.create_config('/vm-pool/pool', pool_config)
        pool = proxy.get("/vm-pool/pool[name='%s']" % vm_pool_name)
        assigned_ids = [vm.id for vm in pool.assigned]
        assert len(assigned_ids) == 0
Esempio n. 8
0
 def test_assign_port_pool_to_mgmt_domain(self, proxy, mgmt_domain_name,
                                          port_pool_name):
     '''Configure mgmt_domain by adding a port pool to it
     '''
     pool_config = RwMcYang.MgmtDomainPools_Port(name=port_pool_name)
     proxy.create_config(
         "/mgmt-domain/domain[name='%s']/pools/port" % mgmt_domain_name,
         pool_config)
Esempio n. 9
0
 def test_assign_vm_pool_to_mgmt_domain(self, proxy, mgmt_domain_name,
                                        vm_pool_name):
     '''Configure mgmt_domain by adding a VM pool to it
     '''
     pool_config = RwMcYang.MgmtDomainPools_Vm(name=vm_pool_name)
     proxy.create_config(
         "/mgmt-domain/domain[name='%s']/pools/vm" % mgmt_domain_name,
         pool_config)
Esempio n. 10
0
 def test_assign_network_pool_to_mgmt_domain(self, proxy, mgmt_domain_name,
                                             network_pool_name):
     '''Configure mgmt_domain by adding a network pool to it
     '''
     pool_config = RwMcYang.MgmtDomainPools_Network(name=network_pool_name)
     proxy.create_config(
         "/mgmt-domain/domain[name='%s']/pools/network" % mgmt_domain_name,
         pool_config)
Esempio n. 11
0
def run_rpc_perf_test(proxy, num_rpcs=1):
    start_time = time.time()

    for i in range(1, num_rpcs + 1):
        start = RwMcYang.StartLaunchpadInput()
        start.federation_name = "lp_%s" % i
        print(proxy.rpc(start.to_xml(yang_model)))

    stop_time = time.time()

    print("Retrieved %s rpc in %s seconds" %
          (num_rpcs, stop_time - start_time))
    return (stop_time - start_time)
Esempio n. 12
0
    def test_create_mgmt_domain(self, proxy, mgmt_domain_name):
        '''Configure a management domain

        Arguments:
            proxy            - a pytest fixture proxy to RwMcYang
            mgmt_domain_name - a pytest fixture for the management domain name

        Asserts:
            None

        '''
        domain_config = RwMcYang.MgmtDomain(name=mgmt_domain_name)
        proxy.create_config('/mgmt-domain/domain', domain_config)
Esempio n. 13
0
def run_federation_config_perf_test(proxy, num_federations=1):
    start_time = time.time()

    for i in range(1, num_federations + 1):
        fed = RwMcYang.FederationConfig()
        fed.name = "foobar_%s" % i
        print(proxy.merge_config(fed.to_xml(yang_model)))

    stop_time = time.time()

    print("Configured %s federations using netconf in %s seconds" %
          (num_federations, stop_time - start_time))
    return (stop_time - start_time)
Esempio n. 14
0
    def test_create_odl_sdn_account(self, proxy, sdn_account_name,
                                    sdn_account_type):
        '''Configure sdn account

        Asserts:
            SDN name and accout type.
        '''
        sdn_account = RwMcYang.SDNAccount(name=sdn_account_name,
                                          account_type=sdn_account_type)
        xpath = "/sdn/account[name='%s']" % sdn_account_name
        proxy.create_config(xpath, sdn_account)

        print(sdn_account)
        sdn_account = proxy.get(xpath)
Esempio n. 15
0
    def test_create_vm_pool(self, proxy, cloud_account_name, vm_pool_name):
        '''Configure vm pool

        Asserts :
            Newly configured vm pool has no resources assigned to it
        '''
        pool_config = RwMcYang.VmPool(name=vm_pool_name,
                                      cloud_account=cloud_account_name)
        proxy.create_config('/vm-pool/pool', pool_config)

        pool = proxy.get("/vm-pool/pool[name='%s']" % vm_pool_name)
        assigned_ids = [vm.id for vm in pool.assigned]
        assert assigned_ids == [
        ]  # pool contained resources before any were assigned
Esempio n. 16
0
    def test_create_port_pool(self, proxy, cloud_account_name, port_pool_name):
        '''Configure port pool

        Asserts :
            Newly configured port pool has no resources assigned to it
        '''
        pool_config = RwMcYang.PortPool(name=port_pool_name,
                                        cloud_account=cloud_account_name)
        proxy.create_config('/port-pool/pool', pool_config)

        pool = proxy.get("/port-pool/pool[name='%s']" % port_pool_name)
        assigned_ids = [port.id for port in pool.assigned]
        assert assigned_ids == [
        ]  # pool contained resources before any were assigned
Esempio n. 17
0
    def test_create_mgmt_domain(self, proxy, mgmt_domain_name):
        '''Configure mgmt domain

        Asserts:
            If the launchpad configuration is created and updated succesfully.
        '''
        xpath = '/mgmt-domain/domain'
        domain_config = RwMcYang.MgmtDomain(name=mgmt_domain_name)
        proxy.create_config(xpath, domain_config)

        xpath += "[name='{}']".format(mgmt_domain_name)
        proxy.merge_config(xpath, domain_config)

        response = proxy.get(xpath)
        assert response.launchpad.state == 'pending'
Esempio n. 18
0
    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
Esempio n. 19
0
    def test_create_vm_pool_with_null_pool_name(self, proxy, cloud_account):
        '''Tests that a vm pool cannot be created without a name

        Arguments:
            proxy         - a pytest fixture proxy to RwMcYang
            cloud_account - a pytest fixture for the cloud account

        Asserts:
            Cloud account has a name
            rift.auto.proxy.ProxyRequestError is raised

        '''
        assert cloud_account.name is not None
        with pytest.raises(TypeError):
            pool_config = RwMcYang.VmPool(
                name=None,
                cloud_account=cloud_account.name,
                dynamic_scaling=True,
            )
Esempio n. 20
0
    def test_stop_launchpad_redux(self, proxy, mgmt_domain_name):
        '''Invoke stop launchpad RPC... Again...

        Asserts:
            Launchpad begins test in state 'started'
            Launchpad finishes test in state 'stopped'
        '''
        proxy.wait_for("/mgmt-domain/domain[name='%s']/launchpad/state" %
                       mgmt_domain_name,
                       'started',
                       timeout=10,
                       fail_on=['crashed'])
        stop_launchpad_input = RwMcYang.StopLaunchpadInput(
            mgmt_domain=mgmt_domain_name)
        stop_launchpad_output = proxy.rpc(stop_launchpad_input)
        proxy.wait_for("/mgmt-domain/domain[name='%s']/launchpad/state" %
                       mgmt_domain_name,
                       'stopped',
                       timeout=60,
                       fail_on=['crashed'])
Esempio n. 21
0
    def test_start_launchpad(self, proxy, mgmt_domain_name, launchpad_scraper):
        '''Invoke start launchpad RPC

        Asserts:
            Launchpad begins test in state 'stopped'
            Launchpad finishes test in state 'started'
        '''
        proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'stopped',
                timeout=10,
                fail_on=['crashed'])
        start_launchpad_input = RwMcYang.StartLaunchpadInput(mgmt_domain=mgmt_domain_name)
        start_launchpad_output = proxy.rpc(start_launchpad_input)
        proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'started',
                timeout=400,
                fail_on=['crashed'])
        launchpad_scraper.reset()
Esempio n. 22
0
def start_launchpad(proxy, mgmt_domain_name):
    '''Invoke start launchpad RPC

    Arguments:
        mgmt_domain_name - the management domain name string

    Asserts:
        Launchpad begins test in state 'stopped'
        Launchpad finishes test in state 'started'

    '''
    proxy.wait_for(
            "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
            'stopped',
            timeout=10,
            fail_on=['crashed'])
    start_launchpad_input = RwMcYang.StartLaunchpadInput(mgmt_domain=mgmt_domain_name)
    start_launchpad_output = proxy.rpc(start_launchpad_input)
    proxy.wait_for(
            "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
            'started',
            timeout=120,
            fail_on=['crashed'])
Esempio n. 23
0
    def test_start_lp_with_empty_vm_pool(self, proxy, mgmt_domain_name, vm_pool_name):
        '''Tests that starting launchpad fails when vm pool does not have a vm
        Configure mgmt_domain by adding a VM pool to it

        Arguments:
            mgmt_domain_name - a pytest fixture for the management domain name
            vm_pool_name     - a pytest fixture for the vm pool name

        Asserts:
            rift.auto.session.ProxyExpectTimeoutError is raised

        '''
        with pytest.raises(ProxyExpectTimeoutError):
            pool_config = RwMcYang.MgmtDomainPools_Vm(name=vm_pool_name)
            proxy.create_config(
                "/mgmt-domain/domain[name='%s']/pools/vm" % mgmt_domain_name,
                pool_config,
            )
            proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'started',
                timeout=120,
                fail_on=['crashed'])
Esempio n. 24
0
    def test_stop_launchpad(self, proxy, mgmt_domain_name):
        '''Stop launchpad before we leave this class

        Arguments:
            proxy            - a pytest fixture proxy to RwMcYang
            mgmt_domain_name - a pytest fixture for the management domain

        Asserts:
            Launchpad begins test in state 'started'
            Launchpad finishes test in state 'stopped'

        '''
        proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'started',
                timeout=10,
                fail_on=['crashed'])
        stop_launchpad_input = RwMcYang.StopLaunchpadInput(mgmt_domain=mgmt_domain_name)
        stop_launchpad_output = proxy.rpc(stop_launchpad_input)
        proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'stopped',
                timeout=120,
                fail_on=['crashed'])
Esempio n. 25
0
    def test_verify_launchpad_not_started(self, proxy, mgmt_domain_name):
        '''Verifies that the launchpad is not started

        Arguments:
            proxy            - a pytest fixture proxy to RwMcYang
            mgmt_domain_name - a pytest fixture for the management domain name

        Asserts:
            rift.auto.session.ProxyExpectTimeoutError is raised

        '''
        with pytest.raises(ProxyExpectTimeoutError):
            proxy.wait_for(
                    "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                    'started',
                    timeout=10,
                    fail_on=['crashed'])
            stop_launchpad_input = RwMcYang.StopLaunchpadInput(mgmt_domain=mgmt_domain_name)
            stop_launchpad_output = proxy.rpc(stop_launchpad_input)
            proxy.wait_for(
                "/mgmt-domain/domain[name='%s']/launchpad/state" % mgmt_domain_name,
                'stopped',
                timeout=120,
                fail_on=['crashed'])
Esempio n. 26
0
    def test_delete_cloud_account_with_vm_pool_with_vm_resources(
            self, proxy, cloud_account, vm_pool_name):
        '''Tests that a cloud account cannot be deleted if it has a vm pool

        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 primary vm pool name

        Asserts:
            A cloud account exists for the cloud_account_name
            Newly configured vm pool has no resources assigned to it
            Cloud account has available resources
            VM pool has has available resources
            Cloud account and vm pool agree on available resources
            Configured resource is reflected as assigned in operational data
            post assignment
            rift.auto.proxy.ProxyRequestError is raised

        '''
        xpath = "/cloud-account/account[name='%s']" % cloud_account.name
        cloud_account = proxy.get(xpath)
        assert cloud_account is not None

        pool_config = RwMcYang.VmPool(
            name=vm_pool_name,
            cloud_account=cloud_account.name,
            dynamic_scaling=True,
        )
        proxy.create_config('/vm-pool/pool', pool_config)
        pool = proxy.get("/vm-pool/pool[name='%s']" % vm_pool_name)
        assigned_ids = [vm.id for vm in pool.assigned]
        assert len(assigned_ids
                   ) == 0  # pool contained resources before any were assigned

        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 pool has available resources
        # 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  # Configured resource shows as assigned

        xpath = "/cloud-account/account[name='%s']" % cloud_account.name
        with pytest.raises(ProxyRequestError):
            proxy.delete_config(xpath)
Esempio n. 27
0
 def test_create_mgmt_domain(self, proxy, mgmt_domain_name):
     '''Configure mgmt domain'''
     domain_config = RwMcYang.MgmtDomain(name=mgmt_domain_name)
     proxy.create_config('/mgmt-domain/domain', domain_config)