def get_controller_based_on_vni(self, controller_list, vxlanid=0):
        """ Method to get vni corresponding controller
        nvp-controller # show control-cluster logical-switches vni 9647
        VNI      Controller      BUM-Replication ARP-Proxy Connections VTEPs
        9647     10.144.136.238  Enabled         Enabled   0           0

        """
        vni_table = []
        if (vxlanid == 0):
            vxlanid = self.read().vdnId
        cli = BaseCLIClient()
        cli.set_schema_class('vni_schema.VNISchema')
        cli.set_create_endpoint("show control-cluster logical-switches vni " +\
                           str(vxlanid))
        ssh = controller_list[0].get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        vni_entry_list = cli_data.table
        ssh.close()
        if (len(vni_entry_list) == 0):
            """ no vxlanid info on controller"""
            return "FAILURE"
        controllerIP = vni_entry_list[0].controller
        for controller in controller_list:
            if controller.get_ip() == controllerIP:
                return controller
        return "FAILURE"
    def get_controller_based_on_vni(self, controller_list, vxlanid = 0):
        """ Method to get vni corresponding controller
        nvp-controller # show control-cluster logical-switches vni 9647
        VNI      Controller      BUM-Replication ARP-Proxy Connections VTEPs
        9647     10.144.136.238  Enabled         Enabled   0           0

        """
        vni_table = []
        if (vxlanid == 0):
            vxlanid = self.read().vdnId
        cli = BaseCLIClient()
        cli.set_schema_class('vni_schema.VNISchema')
        cli.set_create_endpoint("show control-cluster logical-switches vni " +\
                           str(vxlanid))
        ssh = controller_list[0].get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        vni_entry_list = cli_data.table
        ssh.close()
        if (len(vni_entry_list) == 0):
            """ no vxlanid info on controller"""
            return "FAILURE"
        controllerIP = vni_entry_list[0].controller
        for controller in controller_list:
            if controller.get_ip() == controllerIP:
               return controller
        return "FAILURE"
Exemple #3
0
 def execute_bash_command(self, command):
     """ Method to execute simple command on Proton Server"""
     cli = BaseCLIClient()
     cli.set_schema_class('no_stdout_schema.NoStdOutSchema')
     cli.set_create_endpoint(command)
     ssh = self.get_ssh_connection()
     cli.set_connection(ssh)
     cli_data = cli.read()
     self.log.debug("CLI Data: %s" % cli_data)
     ssh.close()
     return "SUCCESS"
Exemple #4
0
 def execute_bash_command(self, command):
    """ Method to execute simple command on Proton Server"""
    cli = BaseCLIClient()
    cli.set_schema_class('no_stdout_schema.NoStdOutSchema')
    cli.set_create_endpoint(command)
    ssh = self.get_ssh_connection()
    cli.set_connection(ssh)
    cli_data = cli.read()
    self.log.debug("CLI Data: %s" % cli_data)
    ssh.close()
    return "SUCCESS"
    def create_cli_client(self):
        """ Create a new cli client obj and sets all attributes in it

        @param None
        @return BaseCLIClient object
        """

        base_cli_client = BaseCLIClient()
        base_cli_client.set_create_endpoint(self.end_point)
        base_cli_client.set_execution_type(self.call_type)
        base_cli_client.set_schema_class(self.get_tool_schema())
        return base_cli_client
 def set_cmd_on_controller(self, endpoint, value):
     """ Method to set command on  controller, like:
     nvp-controller # set control-cluster core cluster-param divvy_num_nodes_required 3
     while "set control-cluster core cluster-param divvy_num_nodes_required" is the endpoint,
     '3' is the value"
     """
     cli = BaseCLIClient()
     cli.set_schema_class('no_stdout_schema.NoStdOutSchema')
     cli.set_create_endpoint(endpoint + " " + str(value))
     ssh = self.get_ssh_connection()
     cli.set_connection(ssh)
     result_obj = cli.create()
     schema_obj = cli.read_response(result_obj)
     ssh.close()
     if result_obj.status_code != int(0):
         if schema_object.stdout != '':
             self.log.info(
                 "set command on controller failed, output is not empty")
             return "FAILURE"
     return "SUCCESS"
 def set_cmd_on_controller(self, endpoint, value):
     """ Method to set command on  controller, like:
     nvp-controller # set control-cluster core cluster-param divvy_num_nodes_required 3
     while "set control-cluster core cluster-param divvy_num_nodes_required" is the endpoint,
     '3' is the value"
     """
     cli = BaseCLIClient()
     cli.set_schema_class('no_stdout_schema.NoStdOutSchema')
     cli.set_create_endpoint(endpoint + " " + str(value))
     ssh = self.get_ssh_connection()
     cli.set_connection(ssh)
     result_obj = cli.create()
     schema_obj = cli.read_response(result_obj)
     ssh.close()
     if result_obj.status_code != int(0):
         if schema_object.stdout != '':
             self.log.info("set command on controller failed, output is not empty")
             return "FAILURE"
     return "SUCCESS"
    def create_cli_client(self):
        """ Create a new cli client obj and sets all attributes in it

        @param None
        @return BaseCLIClient object
        """

        base_cli_client = BaseCLIClient()
        base_cli_client.set_create_endpoint(self.end_point)
        base_cli_client.set_execution_type(self.call_type)
        base_cli_client.set_schema_class(self.get_tool_schema())
        return base_cli_client
    def get_delay_divvy_num(self):
        """ Method to get delay divvy num on  controller
        nvp-controller # show control-cluster core cluster-param divvy_num_nodes_required
        divvy_num_nodes_required: 1

        """
        cli = BaseCLIClient()
        cli.set_schema_class('divvy_num_schema.DivvyNumSchema')
        cli.set_create_endpoint(
            "show control-cluster core cluster-param divvy_num_nodes_required")
        ssh = self.get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        divvy_num_entry_list = cli_data.table
        ssh.close()
        if (len(divvy_num_entry_list) == 0):
            return "FAILURE"
        divvy_num = divvy_num_entry_list[0].divvy
        return divvy_num
    def get_delay_divvy_num(self):
        """ Method to get delay divvy num on  controller
        nvp-controller # show control-cluster core cluster-param divvy_num_nodes_required
        divvy_num_nodes_required: 1

        """
        cli = BaseCLIClient()
        cli.set_schema_class('divvy_num_schema.DivvyNumSchema')
        cli.set_create_endpoint("show control-cluster core cluster-param divvy_num_nodes_required")
        ssh = self.get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        divvy_num_entry_list = cli_data.table
        ssh.close()
        if (len(divvy_num_entry_list) == 0):
            return "FAILURE"
        divvy_num = divvy_num_entry_list[0].divvy
        return divvy_num
Exemple #11
0
    def get_horizontal_table_from_controllers(self, table_type, controller,
                                              exclude_controller_list):
        """ Method to get all horizontal entries for this VNI from controller,
        like get mac-table, arp-table and so on
        nvp-controller #  show control-cluster logical-switches arp-table 6796
        VNI      IP              MAC               Connection-ID
        6796     192.168.139.11  00:50:56:b2:30:6e 1
        6796     192.168.138.131 00:50:56:b2:40:33 2
        6796     192.168.139.201 00:50:56:b2:75:d1 3

        we expect these arp entries only exist on controller, and should not exist in
        the exclude_controller_list

        """
        vxlanid = self.read().vdnId
        cli = BaseCLIClient()
        # Get the cli_schema_class name e.g. arp-table maps to ARPTableSchema
        schema_class = self.get_cli_schema_class(table_type)
        if schema_class is None:
            self.log.error("schema class not found for table type %s" %
                           table_type)
        cli.set_schema_class(schema_class)
        cli.set_create_endpoint("show control-cluster logical-switches " +
                                table_type + " " + vxlanid)
        ssh = controller.get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        ssh.close()
        for exclude_controller in exclude_controller_list:
            cli.set_schema_class(schema_class)
            ssh = exclude_controller.get_ssh_connection()
            cli.set_connection(ssh)
            cli_data_exclude_controller = cli.read()
            ssh.close()
            if (len(cli_data_exclude_controller.table) > 0):
                self.log.error("expect not found entry on controler  " +\
                               exclude_controller.get_ip() + " but actually we found it")
                return "FAILURE"
        return cli_data.table
Exemple #12
0
    def get_horizontal_table_from_controllers(self, table_type, controller, exclude_controller_list):
        """ Method to get all horizontal entries for this VNI from controller,
        like get mac-table, arp-table and so on
        nvp-controller #  show control-cluster logical-switches arp-table 6796
        VNI      IP              MAC               Connection-ID
        6796     192.168.139.11  00:50:56:b2:30:6e 1
        6796     192.168.138.131 00:50:56:b2:40:33 2
        6796     192.168.139.201 00:50:56:b2:75:d1 3

        we expect these arp entries only exist on controller, and should not exist in
        the exclude_controller_list

        """
        vxlanid = self.read().vdnId
        cli = BaseCLIClient()
        # Get the cli_schema_class name e.g. arp-table maps to ARPTableSchema
        schema_class = self.get_cli_schema_class(table_type)
        if schema_class is None:
            self.log.error("schema class not found for table type %s" % table_type)
        cli.set_schema_class(schema_class)
        cli.set_create_endpoint("show control-cluster logical-switches " + table_type + " " + vxlanid)
        ssh = controller.get_ssh_connection()
        cli.set_connection(ssh)
        cli_data = cli.read()
        ssh.close()
        for exclude_controller in exclude_controller_list:
            cli.set_schema_class(schema_class)
            ssh = exclude_controller.get_ssh_connection()
            cli.set_connection(ssh)
            cli_data_exclude_controller = cli.read()
            ssh.close()
            if (len(cli_data_exclude_controller.table) > 0):
               self.log.error("expect not found entry on controler  " +\
                              exclude_controller.get_ip() + " but actually we found it")
               return "FAILURE"
        return cli_data.table