Exemple #1
0
 def take_action(self, parsed_args):
     LOG.debug('Get parsed_args: %s' % parsed_args)
     LOG.debug('Agent is %s' % parsed_args.agent)
     LOG.debug('Interface is %s' % parsed_args.interface)
     server = setup_server(parsed_args.agent)
     res = server.teardown_link(parsed_args.interface)
     if not res['code']:
         Logger.log_normal("Delete interface success.")
     else:
         Logger.log_fail(res['message'])
Exemple #2
0
 def take_action(self, parsed_args):
     LOG.debug('Get parsed_args: %s' % parsed_args)
     LOG.debug('Agent is %s' % parsed_args.agent)
     LOG.debug('Interface is %s' % parsed_args.interface)
     server = setup_server(parsed_args.agent)
     res = server.teardown_link(parsed_args.interface)
     if not res['code']:
         Logger.log_normal("Delete interface success.")
     else:
         Logger.log_fail(res['message'])
Exemple #3
0
    def take_action(self, parsed_args):
        LOG.debug('Get parsed_args: %s' % parsed_args)
        serverA = setup_server(parsed_args.agentA)
        serverB = setup_server(parsed_args.agentB)
        interface = parsed_args.interface + '.' + parsed_args.vlan_id
        # First of all, check the interface existence
        serverA_interface_existence = serverA.get_interface(interface)
        serverB_interface_existence = serverB.get_interface(interface)

        if serverA_interface_existence['code'] == 1:
            msg = ("Agent: %s has no interface named %s!"
                   "This interface will be created." % (parsed_args.agentA,
                                                        interface))
            Logger.log_fail(msg)
            resA = serverA.add_vlan_to_interface(parsed_args.interface,
                                                 parsed_args.vlan_id)
            LOG.debug('Create interface success for %s' % resA)
        if serverB_interface_existence['code'] == 1:
            msg = ("Agent: %s has no interface named %s!"
                   "This interface will be created." % (parsed_args.agentB,
                                                        interface))
            Logger.log_fail(msg)
            resB = serverB.add_vlan_to_interface(parsed_args.interface,
                                                 parsed_args.vlan_id)
            LOG.debug('Create interface success for %s' % resB)
        # setup link in each agent
        ipA = SETUP_LINK_IP_PRE + parsed_args.agentA.split('-')[1] + '/24'
        resA = serverA.setup_link(interface, ipA)
        LOG.debug('Response is %s' % resA)
        ipB = SETUP_LINK_IP_PRE + parsed_args.agentB.split('-')[1] + '/24'
        resB = serverB.setup_link(interface, ipB)
        LOG.debug('Response is %s' % resB)
        # ping a agent from exists IP to check connectivity
        res = serverA.ping(ips=[ipB])
        # teardown the interface if steth created it.
        if serverA_interface_existence['code']:
            resA = serverA.teardown_link(interface)
        if serverB_interface_existence['code']:
            resB = serverB.teardown_link(interface)
        if res['code'] == 0:
            Logger.log_normal("Packet loss is %s%%" % res['data'].values()[0])
            sys.exit()
        msg = "Error happens because %s" % res['message']
        Logger.log_fail(msg)
Exemple #4
0
    def take_action(self, parsed_args):
        LOG.debug('Get parsed_args: %s' % parsed_args)
        serverA = setup_server(parsed_args.agentA)
        serverB = setup_server(parsed_args.agentB)
        interface = parsed_args.interface + '.' + parsed_args.vlan_id
        # First of all, check the interface existence
        serverA_interface_existence = serverA.get_interface(interface)
        serverB_interface_existence = serverB.get_interface(interface)

        if serverA_interface_existence['code'] == 1:
            msg = ("Agent: %s has no interface named %s!"
                   "This interface will be created." %
                   (parsed_args.agentA, interface))
            Logger.log_fail(msg)
            resA = serverA.add_vlan_to_interface(parsed_args.interface,
                                                 parsed_args.vlan_id)
            LOG.debug('Create interface success for %s' % resA)
        if serverB_interface_existence['code'] == 1:
            msg = ("Agent: %s has no interface named %s!"
                   "This interface will be created." %
                   (parsed_args.agentB, interface))
            Logger.log_fail(msg)
            resB = serverB.add_vlan_to_interface(parsed_args.interface,
                                                 parsed_args.vlan_id)
            LOG.debug('Create interface success for %s' % resB)
        # setup link in each agent
        ipA = SETUP_LINK_IP_PRE + parsed_args.agentA.split('-')[1] + '/24'
        resA = serverA.setup_link(interface, ipA)
        LOG.debug('Response is %s' % resA)
        ipB = SETUP_LINK_IP_PRE + parsed_args.agentB.split('-')[1] + '/24'
        resB = serverB.setup_link(interface, ipB)
        LOG.debug('Response is %s' % resB)
        # ping a agent from exists IP to check connectivity
        res = serverA.ping(ips=[ipB])
        # teardown the interface if steth created it.
        if serverA_interface_existence['code']:
            resA = serverA.teardown_link(interface)
        if serverB_interface_existence['code']:
            resB = serverB.teardown_link(interface)
        if res['code'] == 0:
            Logger.log_normal("Packet loss is %s%%" % res['data'].values()[0])
            sys.exit()
        msg = "Error happens because %s" % res['message']
        Logger.log_fail(msg)
Exemple #5
0
 def take_action(self, parsed_args):
     LOG.debug('Get parsed_args: %s' % parsed_args)
     server = setup_server(parsed_args.agent)
     dest = parsed_args.destination.split(',')
     for ip in dest:
         if utils.is_ip(ip):
             Logger.log_fail("%s is invalid." % ip)
             sys.exit()
     Logger.log_normal("Ping start...")
     res = server.ping(ips=dest,
                       count=parsed_args.count,
                       timeout=parsed_args.timeout,
                       interface=parsed_args.interface)
     LOG.debug('Response is %s' % res)
     if res['code'] == 1:
         Logger.log_fail(res['message'])
         sys.exit()
     if res['code'] == 0:
         return (('Destination', 'Packet Loss (%)'),
                 ((k, v) for k, v in res['data'].items()))
     return (['Error Mssage', ' '], [('message', res['message'])])
Exemple #6
0
 def take_action(self, parsed_args):
     LOG.debug('Get parsed_args: %s' % parsed_args)
     server = setup_server(parsed_args.agent)
     dest = parsed_args.destination.split(',')
     for ip in dest:
         if utils.is_ip(ip):
             Logger.log_fail("%s is invalid." % ip)
             sys.exit()
     Logger.log_normal("Ping start...")
     res = server.ping(ips=dest,
                       count=parsed_args.count,
                       timeout=parsed_args.timeout,
                       interface=parsed_args.interface)
     LOG.debug('Response is %s' % res)
     if res['code'] == 1:
         Logger.log_fail(res['message'])
         sys.exit()
     if res['code'] == 0:
         return (('Destination', 'Packet Loss (%)'),
                 ((k, v) for k, v in res['data'].items()))
     return (['Error Mssage', ' '], [('message', res['message'])])
Exemple #7
0
 def take_action(self, parsed_args):
     self.log.debug('Get parsed_args: %s' % parsed_args)
     server = setup_server(parsed_args.server_agent)
     client = setup_server(parsed_args.client_agent)
     iperf_server_pdid = None
     # setup iperf server
     res = server.setup_iperf_server(protocol=parsed_args.server_protocol,
                                     port=parsed_args.server_port)
     self.log.debug('Response is %s' % res)
     if res['code'] != 0:
         Logger.log_fail(res['message'])
         sys.exit()
     if res['code'] == 0:
         msg = (('Iperf server setup success and runs in '
                 'pid:%s') % (res['data']['pid']))
         self.log.debug(msg)
         iperf_server_pdid = res['data']['pid']
     if parsed_args.iperf_server_type == MGMT_TYPE or \
        parsed_args.iperf_server_type == NET_TYPE or \
        parsed_args.iperf_server_type == STORAGE_TYPE:
         host = utils.get_ip_from_agent(parsed_args.server_agent,
                                        parsed_args.iperf_server_type)
         bandwidth = parsed_args.client_bandwidth
         # setup iperf client
         res = self.take_iperf_client(client=client,
                                      protocol=parsed_args.client_protocol,
                                      host=host,
                                      timeout=parsed_args.client_timeout,
                                      parallel=parsed_args.client_parallel,
                                      bandwidth=bandwidth,
                                      port=parsed_args.client_port)
         self.log.debug('Response is %s' % res)
         # kill iperf server
         r = server.teardown_iperf_server(iperf_server_pdid)
         if r['code'] == 1:
             Logger.log_fail(r['message'])
         if r['code'] == 0:
             msg = (('Iperf server delete success and '
                     'pid:%s') % (iperf_server_pdid))
             self.log.debug(msg)
         return (('Field', 'Value'),
                 ((k, v) for k, v in res['data'].items()))
     elif parsed_args.iperf_server_type == 'others':
         mgmt_host = MGMT_AGENTS_CONFIG[parsed_args.server_agent]
         net_host = NET_AGENTS_CONFIG[parsed_args.server_agent]
         storage_host = STORAGE_AGENTS_CONFIG[parsed_args.server_agent]
         bandwidth = parsed_args.client_bandwidth
         mgmt_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=mgmt_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         msg = ("Start iperf client from MGMT network success. "
                "Begain network iperf...")
         Logger.log_normal(msg)
         net_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=net_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         msg = ("Start iperf client from NET network success. "
                "Begain storage iperf...")
         Logger.log_normal(msg)
         storage_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=storage_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         # kill iperf server
         r = server.teardown_iperf_server(iperf_server_pdid)
         if r['code'] == 1:
             Logger.log_fail(r['message'])
         if r['code'] == 0:
             msg = (('Iperf server delete success and '
                     'pid:%s') % (iperf_server_pdid))
             self.log.debug(msg)
         if mgmt_res['code'] == 0 and \
            net_res['code'] == 0 and \
            storage_res['code'] == 0:
             mgmt_data = [(k, v) for k, v in mgmt_res['data'].items()]
             net_data = [(k, v) for k, v in net_res['data'].items()]
             storage_data = [(k, v) for k, v in storage_res['data'].items()]
             return (('Field', 'Value'),
                     [('Mgmt Result', ' ')] +
                     mgmt_data +
                     [('Net Result', ' ')] +
                     net_data +
                     [('Storage Result', ' ')] +
                     storage_data)
         msg = ("One of start iperf clients error. Please check.")
         return (['Error Mssage', ' '], [('message', msg)])
     else:
         msg = ("Get unsupport iperf server type: %s. "
                "Please choose from 'net', 'mgmt', 'storage', 'others'. "
                % parsed_args.iperf_server_type)
         Logger.log_fail(msg)
         sys.exit()
Exemple #8
0
 def take_action(self, parsed_args):
     self.log.debug('Get parsed_args: %s' % parsed_args)
     server = setup_server(parsed_args.server_agent)
     client = setup_server(parsed_args.client_agent)
     iperf_server_pdid = None
     # setup iperf server
     res = server.setup_iperf_server(protocol=parsed_args.server_protocol,
                                     port=parsed_args.server_port)
     self.log.debug('Response is %s' % res)
     if res['code'] != 0:
         Logger.log_fail(res['message'])
         sys.exit()
     if res['code'] == 0:
         msg = (('Iperf server setup success and runs in '
                 'pid:%s') % (res['data']['pid']))
         self.log.debug(msg)
         iperf_server_pdid = res['data']['pid']
     if parsed_args.iperf_server_type == MGMT_TYPE or \
        parsed_args.iperf_server_type == NET_TYPE or \
        parsed_args.iperf_server_type == STORAGE_TYPE:
         host = utils.get_ip_from_agent(parsed_args.server_agent,
                                        parsed_args.iperf_server_type)
         bandwidth = parsed_args.client_bandwidth
         # setup iperf client
         res = self.take_iperf_client(client=client,
                                      protocol=parsed_args.client_protocol,
                                      host=host,
                                      timeout=parsed_args.client_timeout,
                                      parallel=parsed_args.client_parallel,
                                      bandwidth=bandwidth,
                                      port=parsed_args.client_port)
         self.log.debug('Response is %s' % res)
         # kill iperf server
         r = server.teardown_iperf_server(iperf_server_pdid)
         if r['code'] == 1:
             Logger.log_fail(r['message'])
         if r['code'] == 0:
             msg = (('Iperf server delete success and '
                     'pid:%s') % (iperf_server_pdid))
             self.log.debug(msg)
         return (('Field', 'Value'), ((k, v)
                                      for k, v in res['data'].items()))
     elif parsed_args.iperf_server_type == 'others':
         mgmt_host = MGMT_AGENTS_CONFIG[parsed_args.server_agent]
         net_host = NET_AGENTS_CONFIG[parsed_args.server_agent]
         storage_host = STORAGE_AGENTS_CONFIG[parsed_args.server_agent]
         bandwidth = parsed_args.client_bandwidth
         mgmt_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=mgmt_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         msg = ("Start iperf client from MGMT network success. "
                "Begain network iperf...")
         Logger.log_normal(msg)
         net_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=net_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         msg = ("Start iperf client from NET network success. "
                "Begain storage iperf...")
         Logger.log_normal(msg)
         storage_res = self.take_iperf_client(
             client=client,
             protocol=parsed_args.client_protocol,
             host=storage_host,
             timeout=parsed_args.client_timeout,
             parallel=parsed_args.client_parallel,
             bandwidth=bandwidth,
             port=parsed_args.client_port)
         # kill iperf server
         r = server.teardown_iperf_server(iperf_server_pdid)
         if r['code'] == 1:
             Logger.log_fail(r['message'])
         if r['code'] == 0:
             msg = (('Iperf server delete success and '
                     'pid:%s') % (iperf_server_pdid))
             self.log.debug(msg)
         if mgmt_res['code'] == 0 and \
            net_res['code'] == 0 and \
            storage_res['code'] == 0:
             mgmt_data = [(k, v) for k, v in mgmt_res['data'].items()]
             net_data = [(k, v) for k, v in net_res['data'].items()]
             storage_data = [(k, v) for k, v in storage_res['data'].items()]
             return (('Field', 'Value'), [('Mgmt Result', ' ')] +
                     mgmt_data + [('Net Result', ' ')] + net_data +
                     [('Storage Result', ' ')] + storage_data)
         msg = ("One of start iperf clients error. Please check.")
         return (['Error Mssage', ' '], [('message', msg)])
     else:
         msg = ("Get unsupport iperf server type: %s. "
                "Please choose from 'net', 'mgmt', 'storage', 'others'. " %
                parsed_args.iperf_server_type)
         Logger.log_fail(msg)
         sys.exit()