def setUp( self ): super( OF_CRUD_Test_Meters, self ).setUp() # ----- PUT ----- ids = ParseTools.get_values( self.xml_input_DOM, METER_ID_TAG_NAME ) data = ( self.host, self.port, ids[METER_ID_TAG_NAME] ) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/meter/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/meter/%s' % data # ----- POST ----- data = ( self.host, self.port ) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/' % data # ----- SAL SERVICE OPERATIONS ----- self.oper_url_add = 'http://%s:%d/restconf/operations/sal-meter:add-meter' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-meter:update-meter' % data self.oper_url_del = 'http://%s:%d/restconf/operations/sal-meter:remove-meter' % data # Modify input data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes : self.data_from_file_input += node.toxml( encoding = 'utf-8' ) # The xml body without data - data come from file (all meter subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:meter:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input
def setUp(self): super(OF_CRUD_Test_Meters, self).setUp() # ----- PUT ----- ids = ParseTools.get_values(self.xml_input_DOM, METER_ID_TAG_NAME) data = (self.host, self.port, ids[METER_ID_TAG_NAME]) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/meter/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/meter/%s' % data # ----- POST ----- data = (self.host, self.port) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/' % data # ----- SAL SERVICE OPERATIONS ----- self.oper_url_add = 'http://%s:%d/restconf/operations/sal-meter:add-meter' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-meter:update-meter' % data self.oper_url_del = 'http://%s:%d/restconf/operations/sal-meter:remove-meter' % data # Modify input data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes: self.data_from_file_input += node.toxml(encoding='utf-8') # The xml body without data - data come from file (all meter subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:meter:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input
def setUp( self ): super( OF_CRUD_Test_Flows, self ).setUp() ids = ParseTools.get_values( self.xml_input_DOM, TABLE_ID_TAG_NAME, FLOW_ID_TAG_NAME ) data = ( self.host, self.port, ids[TABLE_ID_TAG_NAME], ids[FLOW_ID_TAG_NAME] ) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data data = ( self.host, self.port, ids[TABLE_ID_TAG_NAME] ) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s' % data # ---- operations --- self.oper_url_get = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s' % data data = ( self.host, self.port ) self.oper_url_add = 'http://%s:%d/restconf/operations/sal-flow:add-flow' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-flow:update-flow' % data self.oper_url_del = 'http://%s:%d/restconf/operations/sal-flow:remove-flow' % data # Modify input operations data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes: nodeKey = None if node.localName == None else ( node.localName ).encode( 'utf-8', 'ignore' ) if ( nodeKey is None or nodeKey != 'id' ) : self.data_from_file_input += node.toxml( encoding = 'utf-8' ) # The xml body without data - data come from file (all flow's subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:flow:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory" xmlns:finv="urn:opendaylight:flow:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input
def setUp(self): super(OF_CRUD_Test_Flows, self).setUp() ids = ParseTools.get_values(self.xml_input_DOM, TABLE_ID_TAG_NAME, FLOW_ID_TAG_NAME) data = (self.host, self.port, ids[TABLE_ID_TAG_NAME], ids[FLOW_ID_TAG_NAME]) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data data = (self.host, self.port, ids[TABLE_ID_TAG_NAME]) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s' % data # ---- operations --- self.oper_url_get = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s' % data data = (self.host, self.port) self.oper_url_add = 'http://%s:%d/restconf/operations/sal-flow:add-flow' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-flow:update-flow' % data self.oper_url_del = 'http://%s:%d/restconf/operations/sal-flow:remove-flow' % data # Modify input operations data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes: nodeKey = None if node.localName == None else ( node.localName).encode('utf-8', 'ignore') if (nodeKey is None or nodeKey != 'id'): self.data_from_file_input += node.toxml(encoding='utf-8') # The xml body without data - data come from file (all flow's subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:flow:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory" xmlns:finv="urn:opendaylight:flow:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input
def __add_flows(self, act_flow_id): cookie_id = None try: self.log.debug('adding flow id: {0}'.format(act_flow_id)) cookie_id = self.make_cookie_marker('stress', act_flow_id) xml_string = str(xml_template).replace(FLOW_ID_TEMPLATE, str(act_flow_id))\ .replace(COOKIE_TEMPLATE, str(int(cookie_id, 16)))\ .replace(HARD_TO_TEMPLATE, '1200').replace(FLOW_NAME_TEMPLATE,'FooXf{0}'.format(act_flow_id))\ .replace(IPV4DST_TEMPLATE,self.make_ipv4_address(act_flow_id)).replace(PRIORITY_TEMPLATE,str(act_flow_id)) #TestRestartMininet.log.info('loaded xml: {0}'.format(''.join(xml_string.split()))) tree = md.parseString(xml_string) ids = ParseTools.get_values(tree.documentElement, 'table_id', 'id') data = (self.host, self.port, ids['table_id'], ids['id']) url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data # send request via RESTCONF headers = { 'Content-Type': 'application/xml', 'Accept': 'application/xml', } self.log.debug('sending request to url: {0}'.format(url)) rsp = requests.put(url, auth=('admin', 'admin'), data=xml_string, headers=headers, timeout=TO_PUT) self.log.debug('received status code: {0}'.format(rsp.status_code)) self.log.debug('received content: {0}'.format(rsp.text)) assert rsp.status_code == 204 or rsp.status_code == 200, 'Status' \ ' code returned %d' % rsp.status_code # we expect that controller doesn't fail to store flow on switch self.test_class.inc_flow(flow_id=act_flow_id, cookie_id=cookie_id) self.flows += 1 except Exception as e: self.log.error( 'Error storing flow id:{0}, cookie-id:{1}, reason: {2}'.format( act_flow_id, cookie_id, str(e))) self.test_class.inc_error() self.errors += 1
def setUp(self): super(OF_CRUD_Test_Groups, self).setUp() # ----- PUT ----- ids = ParseTools.get_values(self.xml_input_DOM, GROUP_ID_TAG_NAME) data = (self.host, self.port, ids[GROUP_ID_TAG_NAME]) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/group/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/group/%s' % data # ----- POST ----- data = (self.host, self.port) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/' % data # ----- SAL SERVICE OPERATIONS ----- self.oper_url_add = 'http://%s:%d/restconf/operations/sal-group:add-group' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-group:update-group' % data self.oper_delete_url = 'http://%s:%d/restconf/operations/sal-group:remove-group' % data # Modify input data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes: self.data_from_file_input += node.toxml(encoding='utf-8') # The xml body without data - data come from file (all meter subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:group:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input # Modify input data for delete data_from_file_input_del = '' for node in self.xml_input_DOM.documentElement.childNodes: nodeKey = None if node.localName == None else ( node.localName).encode('utf-8', 'ignore') if (nodeKey is None or nodeKey != 'buckets'): data_from_file_input_del += node.toxml(encoding='utf-8') # The xml body without data - data come from file (all group subtags) self.oper_delete_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:group:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % data_from_file_input_del
def setUp( self ): super( OF_CRUD_Test_Groups, self ).setUp() # ----- PUT ----- ids = ParseTools.get_values( self.xml_input_DOM, GROUP_ID_TAG_NAME ) data = ( self.host, self.port, ids[GROUP_ID_TAG_NAME] ) self.conf_url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/group/%s' % data self.oper_url = 'http://%s:%d/restconf/operational/opendaylight-inventory:nodes' \ '/node/openflow:1/group/%s' % data # ----- POST ----- data = ( self.host, self.port ) self.conf_url_post = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/' % data # ----- SAL SERVICE OPERATIONS ----- self.oper_url_add = 'http://%s:%d/restconf/operations/sal-group:add-group' % data self.oper_url_upd = 'http://%s:%d/restconf/operations/sal-group:update-group' % data self.oper_delete_url = 'http://%s:%d/restconf/operations/sal-group:remove-group' % data # Modify input data self.data_from_file_input = '' for node in self.xml_input_DOM.documentElement.childNodes : self.data_from_file_input += node.toxml( encoding = 'utf-8' ) # The xml body without data - data come from file (all meter subtags) self.oper_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:group:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % self.data_from_file_input # Modify input data for delete data_from_file_input_del = '' for node in self.xml_input_DOM.documentElement.childNodes : nodeKey = None if node.localName == None else ( node.localName ).encode( 'utf-8', 'ignore' ) if ( nodeKey is None or nodeKey != 'buckets' ) : data_from_file_input_del += node.toxml( encoding = 'utf-8' ) # The xml body without data - data come from file (all group subtags) self.oper_delete_input_stream = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n' \ '<input xmlns="urn:opendaylight:group:service">\n' \ '%s' \ '<node xmlns:inv="urn:opendaylight:inventory">/inv:nodes/inv:node[inv:id="openflow:1"]</node>\n' \ '</input>' % data_from_file_input_del
def __add_flows(self, act_flow_id): cookie_id = None try: self.log.debug('adding flow id: {0}'.format(act_flow_id)) cookie_id = self.make_cookie_marker('stress', act_flow_id) xml_string = str(xml_template).replace(FLOW_ID_TEMPLATE, str(act_flow_id))\ .replace(COOKIE_TEMPLATE, str(int(cookie_id, 16)))\ .replace(HARD_TO_TEMPLATE, '1200').replace(FLOW_NAME_TEMPLATE,'FooXf{0}'.format(act_flow_id))\ .replace(IPV4DST_TEMPLATE,self.make_ipv4_address(act_flow_id)).replace(PRIORITY_TEMPLATE,str(act_flow_id)) #TestRestartMininet.log.info('loaded xml: {0}'.format(''.join(xml_string.split()))) tree = md.parseString(xml_string) ids = ParseTools.get_values(tree.documentElement, 'table_id', 'id') data = (self.host, self.port, ids['table_id'], ids['id']) url = 'http://%s:%d/restconf/config/opendaylight-inventory:nodes' \ '/node/openflow:1/table/%s/flow/%s' % data # send request via RESTCONF headers = { 'Content-Type': 'application/xml', 'Accept': 'application/xml', } self.log.debug('sending request to url: {0}'.format(url)) rsp = requests.put(url, auth=('admin', 'admin'), data=xml_string, headers=headers, timeout=TO_PUT) self.log.debug('received status code: {0}'.format(rsp.status_code)) self.log.debug('received content: {0}'.format(rsp.text)) assert rsp.status_code == 204 or rsp.status_code == 200, 'Status' \ ' code returned %d' % rsp.status_code # we expect that controller doesn't fail to store flow on switch self.test_class.inc_flow(flow_id=act_flow_id, cookie_id=cookie_id) self.flows += 1 except Exception as e: self.log.error('Error storing flow id:{0}, cookie-id:{1}, reason: {2}'.format(act_flow_id, cookie_id, str(e))) self.test_class.inc_error() self.errors += 1