예제 #1
0
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']
        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"

        self.config_dict = config_dict
예제 #2
0
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))
        '''
        For this test case, instantiate a compute object which is not the same as controller
        '''

        for compute in config_dict['computes']:
            if compute['hostname'] != config_dict['controller']['hostname']:
                self.compute = Compute(compute['hostname'], compute['ip'],
                                       compute['username'],
                                       compute['password'])

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict
예제 #3
0
    def __init__(self, config_dict):
        '''
        Constructor
        '''

        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(
                    compute['hostname'],
                    compute['ip'],
                    compute['username'],
                    compute['password']))

        self.new_tenant = config_dict[
            'openstack_tenant_details']['tenant_name']

        if "tenant_username" in config_dict["openstack_tenant_details"] and config_dict[
                'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict[
                'openstack_tenant_details']['tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict["openstack_tenant_details"] and config_dict[
                'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict[
                'openstack_tenant_details']['tenant_password']
        else:
            self.new_password = "******"

        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.dcnm_ip = config_dict['testbed']['dcnm']['address']
        self.dcnm_sys_username = config_dict['testbed']['dcnm']['sys_username']
        self.dcnm_sys_password = config_dict['testbed']['dcnm']['sys_password']
        self.ldap_username = config_dict['testbed']['dcnm']['ldap_username']
        self.ldap_password = config_dict['testbed']['dcnm']['ldap_password']
        self.config_dict = config_dict
예제 #4
0
class CheckFlowsOnComputeOnDelete(object):
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))
        '''
        For this test case, instantiate a compute object which is not the same as controller
        '''

        for compute in config_dict['computes']:
            if compute['hostname'] != config_dict['controller']['hostname']:
                self.compute = Compute(compute['hostname'], compute['ip'],
                                       compute['username'],
                                       compute['password'])

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):
        del_inst = False

        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            hosts_list = self.computeHosts

            # Create an aggregate with availability zone
            hosts = []
            hosts.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg1,
                                            availability_zone=zone1,
                                            host_list=hosts)

            hosts = []
            hosts.append(hosts_list[1])
            agg2 = self.new_tenant + "_agg_" + hosts_list[1].hostname
            zone2 = self.new_tenant + "_az_" + hosts_list[1].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg2,
                                            availability_zone=zone2,
                                            host_list=hosts)

            # Create instance
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone1)
            print "Host1:", host1
            del_inst = True

            host2 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst2,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone2)
            print "Host2:", host2

            time.sleep(20)  # wait for flows to be added

            # Verify Flows
            vdptool_inst = OvsFlowsCli()
            result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst, self.config_dict, self.compute.ip,
                self.compute.username, self.compute.password, host1[0].name)
            if not result:
                raise Exception("Incorrect OVS flows")

            # delete one instance
            self.controller.deleteKeyPair(new_project_user.tenant.id,
                                          self.new_user, self.new_password)
            print "Deleting the Instance - " + self.new_inst2 + " on " + self.compute.hostname + "..."
            self.controller.deleteInstance(new_project_user.tenant.id,
                                           self.new_user, self.new_password,
                                           self.new_inst2)
            del_inst = False

            print "Waiting for flows to be deleted\n"
            time.sleep(20)  # wait for flows to be deleted

            # Check flows on that same compute (should not exist)
            # Verify Flows
            vdptool_inst = OvsFlowsCli()
            result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst, self.config_dict, self.compute.ip,
                self.compute.username, self.compute.password, host1[0].name)
            if result:
                raise Exception("Flows exist..Incorrect OVS output.\n")

        except Exception as e:
            print "Error:", e
            if del_inst:
                # delete one instance
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                print "Deleting the Instance - " + self.new_inst2 + " on " + self.compute.hostname + "..."
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst2)

            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        print "Done"
        return ReturnValue.SUCCESS

    def cleanup(self):
        print "Cleanup:"
        skip_proj = False
        skip_nova = False

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        hosts_list = self.computeHosts
        if skip_nova is False:
            try:
                agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
                hosts_list1 = []
                hosts_list1.append(hosts_list[0])
                self.controller.deleteAggregate(self.controller,
                                                new_project_user.tenant.id,
                                                self.new_user,
                                                self.new_password, agg1,
                                                hosts_list1)

            except Exception as e:
                print "Error:", e

            try:
                agg2 = self.new_tenant + "_agg_" + hosts_list[1].hostname
                hosts_list2 = []
                hosts_list2.append(hosts_list[1])
                self.controller.deleteAggregate(self.controller,
                                                new_project_user.tenant.id,
                                                self.new_user,
                                                self.new_password, agg2,
                                                hosts_list2)

            except Exception as e:
                print "Error:", e

        if skip_proj is False:

            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1)
            except Exception as e:
                print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
class SameSubnetDiffComputePing(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''

        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):

        try:

            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project
            new_project = self.controller.createProject(self.new_tenant)

            nova = self.controller.get_nova_client(new_project.id,
                                                   self.new_user,
                                                   self.new_password)
            if not nova:
                raise Exception("Nova client not found")

            # Create user
            new_user = self.controller.createUser(
                new_project,
                new_username=self.new_user,
                new_password=self.new_password)

            # Create 1st network
            new_network1 = self.controller.createNetwork(
                self.new_tenant, self.new_network1, self.new_user,
                self.new_password)
            print "New Network:", new_network1

            # Create subnet
            new_subnet1 = self.controller.createSubnet(
                new_network1.get('network').get('id'), self.new_tenant,
                self.new_user, self.new_password, self.new_subnw1)
            print "New Subnetwork:", new_subnet1

            # Create key-pair
            key_pair = self.controller.createKeyPair(new_project.id,
                                                     self.new_user,
                                                     self.new_password)

            # Create security groups and rules
            self.controller.createSecurityGroup(new_project.id, self.new_user,
                                                self.new_password)

            hosts = nova.hosts.list()
            hosts_list = [h for h in hosts if h.zone == "nova"]
            # print "Hosts list:", hosts_list

            # Create an aggregate with availability zone
            agg1 = self.new_tenant + "_agg_" + \
                self.config_dict['computes'][0]['hostname']
            zone1 = self.new_tenant + "_az_" + \
                self.config_dict['computes'][0]['hostname']
            aggregate1 = self.controller.createAggregate(
                new_project.id,
                self.new_user,
                self.new_password,
                agg_name=agg1,
                availability_zone=zone1)

            if hosts_list:
                aggregate1.add_host(hosts_list[0].host_name)
            else:
                raise Exception("No hosts found")

            agg2 = self.new_tenant + "_agg_" + \
                self.config_dict['computes'][1]['hostname']
            zone2 = self.new_tenant + "_az_" + \
                self.config_dict['computes'][1]['hostname']
            aggregate2 = self.controller.createAggregate(
                new_project.id,
                self.new_user,
                self.new_password,
                agg_name=agg2,
                availability_zone=zone2)

            if hosts_list:
                aggregate2.add_host(hosts_list[1].host_name)
            else:
                raise Exception("No hosts found")

            # Create instance
            zones = nova.availability_zones.list()
            for zone in zones:
                zone_name = str(zone.zoneName)
                if zone_name == zone1:
                    print "Launching instance in zone: ", zone_name
                    host1 = self.controller.createInstance(
                        new_project.id,
                        self.new_user,
                        self.new_password,
                        new_network1.get('network').get('id'),
                        self.new_inst1,
                        key_name=key_pair,
                        availability_zone=zone_name)
            print "Host1:", host1

            zones = nova.availability_zones.list()
            for zone in zones:
                zone_name = str(zone.zoneName)
                if zone_name == zone2:
                    print "Launching instance in zone: ", zone_name
                    host2 = self.controller.createInstance(
                        new_project.id,
                        self.new_user,
                        self.new_password,
                        new_network1.get('network').get('id'),
                        self.new_inst2,
                        key_name=key_pair,
                        availability_zone=zone_name)
            print "Host2:", host2

            ip_host1 = str((host1[0].networks[self.new_network1])[0])
            ip_host2 = str((host2[0].networks[self.new_network1])[0])

            # Verify Ping using DHCP namespace
            pingObj = Ping()
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network1.get('network').get('id'), ip_host2)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network1.get('network').get('id'), ip_host1)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

            dhcp_ip = self.new_subnw1[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network1.get('network').get('id'), dhcp_ip)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

        except Exception as e:
            print "Created Exception: ", e
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        return ReturnValue.SUCCESS

    def cleanup(self):

        print "Cleanup:"
        skip_nova = False
        skip_proj = False

        try:
            new_project = self.controller.getProject(self.new_tenant)
            if not new_project:
                print "Project not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                nova = self.controller.get_nova_client(new_project.id,
                                                       self.new_user,
                                                       self.new_password)
                if not nova:
                    print("Nova client not found during cleanup")
                    skip_nova = True
            except Exception as e:
                print "Error:", e

        if skip_nova is False and skip_proj is False:
            try:
                agg1 = self.new_tenant + "_agg_" + \
                    self.config_dict['computes'][0]['hostname']
                aggregate1 = self.controller.getAggregate(new_project.id,
                                                          self.new_user,
                                                          self.new_password,
                                                          agg_name=agg1)
                if not aggregate1:
                    print("Aggregate1 not found during cleanup")
                else:
                    hosts = nova.hosts.list()
                    zone1 = self.new_tenant + "_az_" + \
                        self.config_dict['computes'][0]['hostname']
                    host1 = [h for h in hosts if h.zone == zone1]
                    if host1:
                        aggregate1.remove_host(host1[0].host_name)
                    else:
                        print("Hosts not found during cleanup")
            except Exception as e:
                print "Error:", e

            try:
                if aggregate1:
                    nova.aggregates.delete(aggregate1)
            except Exception as e:
                print "Error:", e

            try:
                agg2 = self.new_tenant + "_agg_" + \
                    self.config_dict['computes'][1]['hostname']
                aggregate2 = self.controller.getAggregate(new_project.id,
                                                          self.new_user,
                                                          self.new_password,
                                                          agg_name=agg2)
                if not aggregate2:
                    print("Aggregate2 not found during cleanup")
                else:
                    zone2 = self.new_tenant + "_az_" + \
                        self.config_dict['computes'][1]['hostname']
                    host2 = [h for h in hosts if h.zone == zone2]
                    if host2:
                        aggregate2.remove_host(host2[0].host_name)
                    else:
                        print("Hosts not found during cleanup")
            except Exception as e:
                print "Error:", e

            try:
                if aggregate2:
                    nova.aggregates.delete(aggregate2)
            except Exception as e:
                print "Error:", e

        if skip_proj is False:
            try:
                self.controller.deleteInstance(new_project.id, self.new_user,
                                               self.new_password,
                                               self.new_inst1)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteInstance(new_project.id, self.new_user,
                                               self.new_password,
                                               self.new_inst2)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project.id, self.new_user,
                                              self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e
        try:
            new_network1 = self.controller.getNetwork(self.new_tenant,
                                                      self.new_network1,
                                                      self.new_user,
                                                      self.new_password)
            if not new_network1:
                print("Network not found during cleanup")
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteNetwork(new_network1['id'], self.new_tenant,
                                          self.new_user, self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            new_user = self.controller.getUser(self.new_user)
            if not new_user:
                print("User not found during cleanup")
            else:
                new_user.delete()
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                new_project.delete()
            except Exception as e:
                print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
예제 #6
0
class GeneralCleanup(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']
        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"

        self.config_dict = config_dict

    def start(self):
        print "In start()..."
        skip_nova = False
        skip_proj = False

        try:
            new_project = self.controller.getProject("admin")
            if not new_project:
                print "Project not found during general cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                nova = self.controller.get_nova_client(new_project.id,
                                                       self.new_user,
                                                       self.new_password)
                if not nova:
                    print("Nova client not found during cleanup")
                    skip_nova = True
            except Exception as e:
                print "Error:", e

        if skip_nova is False and skip_proj is False:
            '''
            try:
                aggregates = self.controller.listAggregates(new_project.id, self.new_user, self.new_password)
                hosts = nova.hosts.list()
                #here assumption is each aggregate has one host
                for agg in aggregates:
                    for host in hosts:
                        agg.remove_host(host)
                for agg in aggregates:
                    nova.aggregates.delete(agg)

            except Exception as e:
                print "Error:", e
            '''
            try:
                instances = self.controller.listInstances(
                    new_project.id, "admin", "cisco123")
                return
                for instance in instances:
                    self.controller.deleteInstance(new_project.id,
                                                   self.new_user,
                                                   self.new_password,
                                                   instance.name)
            except Exception as e:
                print "Error:", e

            try:
                networks = self.controller.listNetworks(
                    new_project.id, self.new_user, self.new_password)
                for network in networks:
                    self.controller.deleteNetwork(network['id'],
                                                  self.new_tenant,
                                                  self.new_user,
                                                  self.new_password)
            except Exception as e:
                print "Error:", e

        try:
            new_user = self.controller.getUser(self.new_user)
            if not new_user:
                print("User not found during cleanup")
            else:
                new_user.delete()
        except Exception as e:
            print "Error:", e
class CheckFlowsOnDelete(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(
            config_dict['controller']['hostname'],
            config_dict['controller']['ip'],
            self.config_dict['controller']['username'],
            self.config_dict['controller']['password'],
            config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.config_dict = config_dict

    def runTest(self):
        del_inst = False
        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            # Create instance
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=None)
            print "Host1:", host1
            del_inst = True

            time.sleep(20)  # wait for flows to be added

            # Verify Flows
            vdptool_inst = OvsFlowsCli()
            result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst, self.config_dict, self.controller.ip,
                self.controller.sys_username, self.controller.password,
                host1[0].name)
            if not result:
                raise Exception("Incorrect OVS flows")

            # Deleting instance and network
            self.controller.deleteKeyPair(new_project_user.tenant.id,
                                          self.new_user, self.new_password)
            print "Deleting Instance " + self.new_inst1 + "..."
            self.controller.deleteInstance(new_project_user.tenant.id,
                                           self.new_user, self.new_password,
                                           self.new_inst1)
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
            del_inst = False

            print "Waiting for flows to be deleted\n"
            time.sleep(20)

            # Verify Flows
            vdptool_inst = OvsFlowsCli()
            result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst, self.config_dict, self.controller.ip,
                self.controller.sys_username, self.controller.password,
                host1[0].name)
            if result:
                del_inst = False
                raise Exception(
                    "Incorrect ovs flows output. Flows still present. Failing the test case...\n"
                )

        except Exception as e:
            print "Created Exception: ", e
            if del_inst:
                # Deleting instance and network
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                print "Deleting Instance " + self.new_inst1 + "..."
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1)
                self.controller.deleteNetwork(self.controller,
                                              self.new_network1,
                                              self.new_tenant, self.new_user,
                                              self.new_password)
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        print "Done"
        return ReturnValue.SUCCESS

    def cleanup(self):

        print "Cleanup:"

        try:
            self.controller.deleteProjectUser(
                self.controller,
                self.controller.getProjectUser(self.new_tenant, self.new_user))
        except Exception as e:
            print "Error:", e

        print "Done cleaning"
        return ReturnValue.SUCCESS
예제 #8
0
class VdpAssoc(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):

        try:

            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            # Create an aggregate with availability zone
            hosts = []
            hosts_list = self.computeHosts
            hosts.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg1,
                                            availability_zone=zone1,
                                            host_list=hosts)

            # Create instance
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone1)
            print "Host1:", host1

            vdptool_inst = VdpToolCli()
            result = VdpToolCli.check_uplink_and_output(
                vdptool_inst, self.config_dict,
                str((host1[0].networks[self.new_network1])[0]), host1[0].name,
                hosts_list[0].hostname)
            if result is False:
                raise Exception("Incorrect vdptool cmd output.\n")

        except Exception as e:
            print "Created Exception: ", e
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        print "Done"
        return ReturnValue.SUCCESS

    def cleanup(self):
        print "Cleanup:"
        skip_proj = False

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        try:
            hosts_list = self.computeHosts
            host = []
            host.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            self.controller.deleteAggregate(self.controller,
                                            new_project_user.tenant.id,
                                            self.new_user, self.new_password,
                                            agg1, host)
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done cleaning"
        return ReturnValue.SUCCESS
예제 #9
0
class VerifyDCNM(object):
    '''
    classdocs
    '''

    def __init__(self, config_dict):
        '''
        Constructor
        '''

        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(
                    compute['hostname'],
                    compute['ip'],
                    compute['username'],
                    compute['password']))

        self.new_tenant = config_dict[
            'openstack_tenant_details']['tenant_name']

        if "tenant_username" in config_dict["openstack_tenant_details"] and config_dict[
                'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict[
                'openstack_tenant_details']['tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict["openstack_tenant_details"] and config_dict[
                'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict[
                'openstack_tenant_details']['tenant_password']
        else:
            self.new_password = "******"

        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.dcnm_ip = config_dict['testbed']['dcnm']['address']
        self.dcnm_sys_username = config_dict['testbed']['dcnm']['sys_username']
        self.dcnm_sys_password = config_dict['testbed']['dcnm']['sys_password']
        self.ldap_username = config_dict['testbed']['dcnm']['ldap_username']
        self.ldap_password = config_dict['testbed']['dcnm']['ldap_password']
        self.config_dict = config_dict

    def runTest(self):
        try:

            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant,
                self.new_network1,
                self.new_subnw1,
                self.new_user,
                self.new_password)

            # This is because results were different without adding delay
            time.sleep(5)

            with SSHConnection(address=self.dcnm_ip, username=self.dcnm_sys_username, password=self.dcnm_sys_password) as client:
                stdin, stdout, stderr = client.exec_command(
                    "ldapsearch -x -v -D 'cn=" + self.ldap_username + ",dc=cisco,dc=com' -w '" + self.ldap_password + "' -b 'dc=cisco,dc=com'")
                output = stdout.readlines()

                # print output
                org_str = "orgName: " + self.new_tenant
                org_found = False
                part_str = "vrfName: " + self.new_tenant + ":CTX"
                part_found = False
                net_str = "networkName: " + self.new_network1
                net_found = False
                for line in output:
                    line = line.strip()
                    if not org_found and org_str in line:
                        print "Organization  created on DCNM"
                        org_found = True
                    if not part_found and part_str in line:
                        print "Partition CTX created on DCNM"
                        part_found = True
                    if not net_found and net_str in line:
                        print "Network  created on DCNM"
                        net_found = True
                if not org_found:
                    raise Exception("Organization NOT found on DCNM")
                elif not part_found:
                    raise Exception("Partition NOT found on DCNM")
                elif not net_found:
                    raise Exception("Network NOT found on DCNM")

        except Exception as e:
            print "Error:", e
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        return ReturnValue.SUCCESS

    def cleanup(self):
        print "Cleanup:"

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"

        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteNetwork(
                self.controller,
                self.new_network1,
                self.new_tenant,
                self.new_user,
                self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(
                self.controller, new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done cleaning"

        return ReturnValue.SUCCESS
class GenericPingSameSubnetDiffCompute(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''

        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeCount = 0
        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))
            self.computeCount = self.computeCount + 1

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst = self.new_tenant + "inst"
        self.config_dict = config_dict

    def runTest(self):

        agg = []
        aggregate = []
        zone = []
        vm = []
        ip_vm = []

        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            hosts_list = self.computeHosts

            for host in range(self.computeCount):
                hosts = []
                # Create an aggregate with availability zone per compute/host
                agg.append(self.new_tenant + "_agg_" +
                           hosts_list[host].hostname)
                zone.append(self.new_tenant + "_az_" +
                            hosts_list[host].hostname)
                hosts.append(hosts_list[host])
                aggregate.append(
                    self.controller.createAggregate(
                        new_project_user.tenant.id,
                        self.new_user,
                        self.new_password,
                        agg_name=agg[host],
                        availability_zone=zone[host],
                        host_list=hosts))

                #aggregate[host].add_host(hosts_list[host].hostname)

                # Create instance
                vm.append(
                    self.controller.createInstance(
                        new_project_user.tenant.id,
                        self.new_user,
                        self.new_password,
                        new_network_inst1.network.get('network').get('id'),
                        self.new_inst + str(host),
                        key_name=keypair_secgrp.key_pair,
                        availability_zone=zone[host]))

                print "VM[" + str(host) + "]:", vm[host]
                ip_vm.append(str((vm[host][0].networks[self.new_network1])[0]))
                print "IP of VM[" + str(host) + "]:", ip_vm[host]

            pingObj = Ping()
            dhcp_ip = self.new_subnw1[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), dhcp_ip)

            if not result:
                raise Exception("Ping failed...Failing test case\n")

            for host in range(self.computeCount):
                # Verify Ping using DHCP namespace
                result = pingObj.verify_ping_qdhcpns(
                    self.controller.ip, self.controller.sys_username,
                    self.controller.password,
                    new_network_inst1.network.get('network').get('id'),
                    ip_vm[host])

                if not result:
                    raise Exception("Ping failed...Failing test case\n")

        except Exception as e:
            print "Created Exception: ", e
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        return ReturnValue.SUCCESS

    def cleanup(self):

        print "Cleanup:"

        skip_proj = False
        agg_list = []
        hosts_list = []

        hosts_list = self.computeHosts
        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                for host in range(self.computeCount):
                    # Create an aggregate with availability zone per
                    # compute/host
                    agg_list.append(self.new_tenant + "_agg_" +
                                    hosts_list[host].hostname)

                self.controller.deleteAggregateList(self.controller,
                                                    new_project_user.tenant.id,
                                                    self.new_user,
                                                    self.new_password,
                                                    agg_list, hosts_list)
            except Exception as e:
                print "Error:", e

        if skip_proj is False:

            for host in range(self.computeCount):
                try:
                    self.controller.deleteInstance(new_project_user.tenant.id,
                                                   self.new_user,
                                                   self.new_password,
                                                   self.new_inst + str(host))
                except Exception as e:
                    print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e
        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
예제 #11
0
class RestartService(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']
        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_network2 = self.new_tenant + "nw2"
        self.new_subnw2 = "10.13.14.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.num_inst = 2
        self.config_dict = config_dict

    def runTest(self, service):

        print "Service to be restarted is:", service

        try:

            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            new_network_inst2 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network2, self.new_subnw2,
                self.new_user, self.new_password)
            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            hosts_list = self.computeHosts

            # Create an aggregate with availability zone
            hosts = []
            hosts.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg1,
                                            availability_zone=zone1,
                                            host_list=hosts)

            hosts = []
            hosts.append(hosts_list[1])
            agg2 = self.new_tenant + "_agg_" + hosts_list[1].hostname
            zone2 = self.new_tenant + "_az_" + hosts_list[1].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg2,
                                            availability_zone=zone2,
                                            host_list=hosts)

            # Create 5 instances on two different computes (total 10 instances)
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone1,
                count=self.num_inst)

            host2 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst2.network.get('network').get('id'),
                self.new_inst2,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone2,
                count=self.num_inst)

            # Verify Ping, ovs flows and uplink & vdptool output using DHCP
            # namespace on controller (before restart)
            pingObj = Ping()

            dhcp_ip1 = self.new_subnw1[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst2.network.get('network').get('id'), dhcp_ip1)

            if not result:
                raise Exception("Ping failed...Failing test case\n")

            dhcp_ip2 = self.new_subnw2[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), dhcp_ip2)

            if not result:
                raise Exception("Ping failed...Failing test case\n")

            inst_ip_list = []

            # Gathering instances information
            for inst in range(self.num_inst):
                print "loop:", inst
                instObj = Instance(ip=str(
                    (host1[inst].networks[self.new_network1])[0]),
                                   instname=str(host1[inst].name),
                                   hostname=hosts_list[0].hostname)
                print "InstObj1:", instObj
                inst_ip_list.append(instObj)
                print "inst_ip_list1:", inst_ip_list
                instObj = Instance(ip=str(
                    (host2[inst].networks[self.new_network2])[0]),
                                   instname=str(host2[inst].name),
                                   hostname=hosts_list[1].hostname)
                print "InstObj2:", instObj
                inst_ip_list.append(instObj)
                print "inst_ip_list2:", inst_ip_list

            # Verify ping, ovs and vdp results
            for inst in inst_ip_list:
                # Verify Ping
                result = pingObj.verify_ping_qdhcpns(
                    self.controller.ip, self.controller.sys_username,
                    self.controller.password,
                    new_network_inst1.network.get('network').get('id'),
                    inst.ip)
                print "network_id is:", new_network_inst1.network.get(
                    'network').get('id')
                if not result:
                    raise Exception("Ping failed...Failing test case\n")

                result = pingObj.verify_ping_qdhcpns(
                    self.controller.ip, self.controller.sys_username,
                    self.controller.password,
                    new_network_inst2.network.get('network').get('id'),
                    inst.ip)
                print "network_id is:", new_network_inst2.network.get(
                    'network').get('id')
                if not result:
                    raise Exception("Ping failed...Failing test case\n")

                OvsFlowsCli().verify_ovs_and_vdp(self.config_dict,
                                                 self.controller.ip,
                                                 self.controller.sys_username,
                                                 self.controller.password,
                                                 inst.instname, inst.ip,
                                                 inst.hostname)
                if not result:
                    raise Exception("Incorrect VDPTool/OVS output")

            # Restart service
            if service == "enabler-server":
                # Restart Enabler server on controller
                enabler_inst = EnablerService(self.controller.ip,
                                              self.controller.sys_username,
                                              self.controller.password)
                result = EnablerService.take_action(enabler_inst, "restart",
                                                    "server")
                if not result:
                    raise Exception("Error while restarting enabler server")

            elif service == "enabler-agent":
                # Restart Enabler agent on controller
                enabler_inst = EnablerService(self.controller.ip,
                                              self.controller.sys_username,
                                              self.controller.password)
                result = EnablerService.take_action(enabler_inst, "restart",
                                                    "agent")
                if not result:
                    raise Exception("Error while restarting enabler agent")

            elif service == "lldpad":
                # Restart lldpad on controller
                lldpad_inst = LldpadService(self.controller.ip,
                                            self.controller.sys_username,
                                            self.controller.password)
                result = LldpadService.take_action(lldpad_inst, "restart")
                if not result:
                    raise Exception("Error while restarting lldpad")

            # Verify Ping, ovs flows and uplink & vdptool output using DHCP
            # namespace on controller (after restart)
            for inst in inst_ip_list:
                # Verify Ping
                result = pingObj.verify_ping_qdhcpns(
                    self.controller.ip, self.controller.sys_username,
                    self.controller.password,
                    new_network_inst1.network.get('network').get('id'),
                    inst.ip)
                print "network_id is:", new_network_inst1.network.get(
                    'network').get('id')
                if not result:
                    raise Exception("Ping failed...Failing test case\n")

                result = pingObj.verify_ping_qdhcpns(
                    self.controller.ip, self.controller.sys_username,
                    self.controller.password,
                    new_network_inst2.network.get('network').get('id'),
                    inst.ip)
                print "network_id is:", new_network_inst2.network.get(
                    'network').get('id')
                if not result:
                    raise Exception("Ping failed...Failing test case\n")

                OvsFlowsCli().verify_ovs_and_vdp(self.config_dict,
                                                 self.controller.ip,
                                                 self.controller.sys_username,
                                                 self.controller.password,
                                                 inst.instname, inst.ip,
                                                 inst.hostname)
                if not result:
                    raise Exception("Incorrect VDPTool/OVS output")

        except Exception as e:
            print "Created Exception: ", e
            return resultConstants.RESULT_ABORT
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        return ReturnValue.SUCCESS

    def cleanup(self):

        print "Cleanup:"
        hosts_list = self.computeHosts
        hosts = []
        skip_proj = False

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
                hosts.append(hosts_list[0])
                self.controller.deleteAggregate(self.controller,
                                                new_project_user.tenant.id,
                                                self.new_user,
                                                self.new_password,
                                                agg_name=agg1,
                                                host_list=hosts)

                hosts = []
                agg2 = self.new_tenant + "_agg_" + hosts_list[1].hostname
                hosts.append(hosts_list[1])
                self.controller.deleteAggregate(self.controller,
                                                new_project_user.tenant.id,
                                                self.new_user,
                                                self.new_password,
                                                agg_name=agg2,
                                                host_list=hosts)

            except Exception as e:
                print "Error:", e

        if skip_proj is False:
            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1,
                                               count=self.num_inst)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst2,
                                               count=self.num_inst)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e
        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network2,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
예제 #12
0
class CheckFlowsOnDeleteOneInst(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):
        del_inst = False
        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            # Create instance
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=None)
            del_inst = True
            print "Host1:", host1

            # Create instance
            host2 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst2,
                key_name=keypair_secgrp.key_pair,
                availability_zone=None)
            print "Host2:", host2

            time.sleep(20)  # wait for flows to be added

            # Verify Flows
            vdptool_inst = OvsFlowsCli()
            result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst, self.config_dict, self.controller.ip,
                self.controller.sys_username, self.controller.password,
                host1[0].name)
            if not result:
                raise Exception("Incorrect OVS flows")

            # Verify that flows are not deleted after deleting one instance on
            # Controller+Compute
            self.controller.deleteKeyPair(new_project_user.tenant.id,
                                          self.new_user, self.new_password)
            print "Deleting only 1 Instance - " + self.new_inst1 + "..."
            self.controller.deleteInstance(new_project_user.tenant.id,
                                           self.new_user, self.new_password,
                                           self.new_inst1)
            del_inst = False

            print "Waiting before checking the flows\n"
            time.sleep(20)  # wait for flows to be deleted

            # Verify if DB has the instance info (Expected : Not found)
            mysql_db = MySqlConnection(self.config_dict)

            with MySqlConnection(self.config_dict) as mysql_connection:
                data = mysql_db.get_instances(mysql_connection, host1[0].name)

            if data is not None:
                raise Exception("DB not cleared for the instance")
                '''
                result = OvsFlowsCli.check_if_exists_in_both_br_flows(
                vdptool_inst,
                self.config_dict,
                self.controller.ip,
                self.controller.sys_username,
                self.controller.password,
                host1[0].name)
            if not result:
                raise Exception("Incorrect OVS flows")'''

        except Exception as e:
            print "Exception:", e
            return resultConstants.RESULT_ABORT
            if del_inst:
                # Deleting instance and network
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                print "Deleting Instance " + self.new_inst1 + "..."
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1)
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        print "Done"
        return ReturnValue.SUCCESS

    def cleanup(self):
        print "Cleanup:"
        skip_proj = False

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:

            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst2)
            except Exception as e:
                print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
예제 #13
0
class CheckVdpKeepAlive(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''
        self.config_dict = config_dict
        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']

        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):

        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project
            new_project = self.controller.createProject(self.new_tenant)

            # Create user
            new_user = self.controller.createUser(
                new_project,
                new_username=self.new_user,
                new_password=self.new_password)

            # Create network
            new_network1 = self.controller.createNetwork(
                self.new_tenant, self.new_network1, self.new_user,
                self.new_password)
            print "New Network:", new_network1

            # Create subnet
            new_subnet = self.controller.createSubnet(
                new_network1.get('network').get('id'), self.new_tenant,
                self.new_user, self.new_password, self.new_subnw1)
            print "New Subnetwork:", new_subnet

            # Create key-pair
            key_pair = self.controller.createKeyPair(new_project.id,
                                                     self.new_user,
                                                     self.new_password)

            # Create security groups and rules
            self.controller.createSecurityGroup(new_project.id, self.new_user,
                                                self.new_password)

            # Create instance
            host1 = self.controller.createInstance(
                new_project.id,
                self.new_user,
                self.new_password,
                new_network1.get('network').get('id'),
                self.new_inst1,
                key_name=key_pair,
                availability_zone=None)
            print "Host1:", host1

            print "Connecting to database"
            # Connect to database
            mysql_db = MySqlConnection(self.config_dict)

            with MySqlConnection(self.config_dict) as mysql_connection:

                data = mysql_db.get_instances(mysql_connection, self.new_inst1)
                print "Host name is:", data[MySqlDbTables.INSTANCES_HOST_NAME]
                host_name = data[MySqlDbTables.INSTANCES_HOST_NAME]

            print "Getting uplink info...\n"

            uplinkInst = Uplink(self.config_dict)
            uplink_info = UplinkInfo()
            uplink_info = Uplink.get_info(uplinkInst, host_name)
            print "uplink switchIp:", uplink_info.switchIp

            fabricSwInst = FabricSwitch(self.config_dict)
            fabric_sw_info = FabricSwitchInfo()
            fabric_sw_info = FabricSwitch.get_info(fabricSwInst,
                                                   uplink_info.switchIp,
                                                   self.config_dict)

            print "Checking for VDP Keep alive on the fabric connection...\n"

            with SSHConnection(address=uplink_info.switchIp,
                               username=fabric_sw_info.username,
                               password=fabric_sw_info.password) as client:
                stdin, stdout, stderr = client.exec_command("show run vlan")
                output = "".join(stdout.readlines()).strip()
                error_output = "".join(stderr.readlines()).strip()
                print "Output:", output

        except Exception as e:
            print "Created Exception: ", e
            self.cleanup()
            return ReturnValue.FAILURE

    def cleanup(self):
        print "Cleanup:"
        skip_proj = False
        skip_nw = False

        try:
            new_project = self.controller.getProject(self.new_tenant)
            if not new_project:
                print "Project not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        if skip_proj is False:

            try:
                self.controller.deleteInstance(new_project.id, self.new_user,
                                               self.new_password,
                                               self.new_inst2)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project.id, self.new_user,
                                              self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e
        try:
            new_network1 = self.controller.getNetwork(self.new_tenant,
                                                      self.new_network1,
                                                      self.new_user,
                                                      self.new_password)
            if not new_network1:
                print("Network not found during cleanup")
                skip_nw = True
        except Exception as e:
            print "Error:", e

        if skip_nw is False:
            try:
                self.controller.deleteNetwork(new_network1['id'],
                                              self.new_tenant, self.new_user,
                                              self.new_password)
            except Exception as e:
                print "Error:", e

        try:
            new_user = self.controller.getUser(self.new_user)
            if not new_user:
                print("User not found during cleanup")
        except Exception as e:
            print "Error:", e

        try:
            new_user.delete()
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                new_project.delete()
            except Exception as e:
                print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS
예제 #14
0
class DiffSubnetSameComputePing(object):
    '''
    classdocs
    '''
    def __init__(self, config_dict):
        '''
        Constructor
        '''

        self.controller = Controller(config_dict['controller']['hostname'],
                                     config_dict['controller']['ip'],
                                     config_dict['controller']['username'],
                                     config_dict['controller']['password'],
                                     config_dict['controller']['sys_username'])

        self.computeHosts = []
        for compute in config_dict['computes']:
            self.computeHosts.append(
                Compute(compute['hostname'], compute['ip'],
                        compute['username'], compute['password']))

        self.new_tenant = config_dict['openstack_tenant_details'][
            'tenant_name']
        if "tenant_username" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_username'] is not None:
            self.new_user = config_dict['openstack_tenant_details'][
                'tenant_username']
        else:
            self.new_user = "******"
        if "tenant_password" in config_dict[
                "openstack_tenant_details"] and config_dict[
                    'openstack_tenant_details']['tenant_password'] is not None:
            self.new_password = config_dict['openstack_tenant_details'][
                'tenant_password']
        else:
            self.new_password = "******"
        self.new_network1 = self.new_tenant + "nw1"
        self.new_subnw1 = "10.11.12.0/24"
        self.new_network2 = self.new_tenant + "nw2"
        self.new_subnw2 = "10.13.14.0/24"
        self.new_inst1 = self.new_tenant + "inst1"
        self.new_inst2 = self.new_tenant + "inst2"
        self.config_dict = config_dict

    def runTest(self):
        try:
            # Basic checks for status of services
            status_inst = CheckStatusOfServices(self.config_dict)
            status = CheckStatusOfServices.check(status_inst)
            if not status:
                print "Some service/s not running...Unable to run testcase"
                return resultConstants.RESULT_ABORT

            # Create project & user
            new_project_user = self.controller.createProjectUser(
                self.new_tenant, self.new_user, self.new_password)

            # Create network and subnetwork
            new_network_inst1 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network1, self.new_subnw1,
                self.new_user, self.new_password)

            # Create 2nd network
            new_network_inst2 = self.controller.createNetworkSubNetwork(
                self.new_tenant, self.new_network2, self.new_subnw2,
                self.new_user, self.new_password)

            # Create key-pair & security groups and rules
            keypair_secgrp = self.controller.createKeyPairSecurityGroup(
                new_project_user.tenant.id, self.new_user, self.new_password)

            hosts = []
            hosts_list = self.computeHosts
            hosts.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            zone1 = self.new_tenant + "_az_" + hosts_list[0].hostname
            self.controller.createAggregate(new_project_user.tenant.id,
                                            self.new_user,
                                            self.new_password,
                                            agg_name=agg1,
                                            availability_zone=zone1,
                                            host_list=hosts)

            # Create instance
            host1 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst1.network.get('network').get('id'),
                self.new_inst1,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone1)
            print "Host1:", host1
            host2 = self.controller.createInstance(
                new_project_user.tenant.id,
                self.new_user,
                self.new_password,
                new_network_inst2.network.get('network').get('id'),
                self.new_inst2,
                key_name=keypair_secgrp.key_pair,
                availability_zone=zone1)
            print "Host2:", host2

            ip_host1 = str((host1[0].networks[self.new_network1])[0])
            ip_host2 = str((host2[0].networks[self.new_network2])[0])

            # Verify Ping using DHCP namespace on controller
            pingObj = Ping()
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), ip_host1)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

            dhcp_ip1 = self.new_subnw1[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), dhcp_ip1)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), ip_host2)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

            dhcp_ip2 = self.new_subnw2[:-4] + "2"
            result = pingObj.verify_ping_qdhcpns(
                self.controller.ip, self.controller.sys_username,
                self.controller.password,
                new_network_inst1.network.get('network').get('id'), dhcp_ip2)
            if not result:
                raise Exception("Ping failed...Failing test case\n")

        except Exception as e:
            print "Created Exception: ", e
            self.cleanup()
            return ReturnValue.FAILURE

        self.cleanup()
        return ReturnValue.SUCCESS

    def cleanup(self):

        print "Cleanup:"
        skip_proj = False

        try:
            new_project_user = self.controller.getProjectUser(
                self.new_tenant, self.new_user)
            if not new_project_user:
                print "Project/User not found during cleanup"
                skip_proj = True
        except Exception as e:
            print "Error:", e

        try:
            hosts_list = self.computeHosts
            host = []
            host.append(hosts_list[0])
            agg1 = self.new_tenant + "_agg_" + hosts_list[0].hostname
            self.controller.deleteAggregate(self.controller,
                                            new_project_user.tenant.id,
                                            self.new_user, self.new_password,
                                            agg1, host)
        except Exception as e:
            print "Error:", e

        if skip_proj is False:
            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst1)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteInstance(new_project_user.tenant.id,
                                               self.new_user,
                                               self.new_password,
                                               self.new_inst2)
            except Exception as e:
                print "Error:", e

            try:
                self.controller.deleteKeyPair(new_project_user.tenant.id,
                                              self.new_user, self.new_password)
                time.sleep(5)
            except Exception as e:
                print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network1,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteNetwork(self.controller, self.new_network2,
                                          self.new_tenant, self.new_user,
                                          self.new_password)
        except Exception as e:
            print "Error:", e

        try:
            self.controller.deleteProjectUser(self.controller,
                                              new_project_user)
        except Exception as e:
            print "Error:", e

        print "Done"
        return ReturnValue.SUCCESS