Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90272

Re: calling base class method fetches no results

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <djhon9813@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'insert': 0.05; 'that?': 0.05; 'url:bitbucket': 0.05; 'debug': 0.07; 'debugging': 0.07; 'method.': 0.07; 'none,': 0.07; 'none:': 0.07; 'paths': 0.07; 'tests.': 0.07; 'advance': 0.07; '#print': 0.09; '[0]': 0.09; 'dst': 0.09; 'function,': 0.09; 'guys.': 0.09; 'lawrence': 0.09; 'method,': 0.09; 'method:': 0.09; 'snippet': 0.09; 'subject:method': 0.09; 'tcp/ip': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'bug': 0.12; 'language.': 0.14; '"""install': 0.16; '"some': 0.16; "'''": 0.16; "','": 0.16; '-1):': 0.16; '-1,': 0.16; 'attaching': 0.16; 'caused.': 0.16; 'dst):': 0.16; 'dst,': 0.16; 'dst:': 0.16; 'elephant': 0.16; 'eliminating': 0.16; 'event):': 0.16; 'fetches': 0.16; 'flow,': 0.16; 'hashed': 0.16; 'instantiated': 0.16; 'lot!': 0.16; 'param': 0.16; 'path.': 0.16; 'paths.': 0.16; 'specific,': 0.16; 'src': 0.16; 'src,': 0.16; 'subject:class': 0.16; 'suggestion.': 0.16; 'switches': 0.16; 'traverse': 0.16; 'true:': 0.16; '\xc2\xa0if': 0.16; 'exception': 0.16; 'sat,': 0.16; 'skip:= 10': 0.16; 'language': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; '&lt;': 0.19; 'everyone,': 0.19; 'pieces': 0.19; 'skip:p 40': 0.19; 'later': 0.20; 'fit': 0.20; 'help.': 0.21; 'seems': 0.21; '8bit%:5': 0.22; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'saying': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'install': 0.23; 'either.': 0.24; 'entries': 0.24; 'specify': 0.24; 'earlier': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'source': 0.25; '&gt;': 0.26; 'logging': 0.26; 'nearly': 0.26; 'post': 0.26; 'defined': 0.27; 'skip:_ 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'point': 0.28; 'host': 0.29; 'skip:p 30': 0.29; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; "skip:' 10": 0.31; '>>>>': 0.31; 'context,': 0.31; 'context.': 0.31; 'description,': 0.31; 'helpful.': 0.31; 'node': 0.31; 'object.': 0.31; 'piece': 0.31; 'skip:= 20': 0.31; 'file': 0.32; 'class': 0.32; 'run': 0.32; '(including': 0.33; 'says': 0.33; 'url:python': 0.33; 'running': 0.33; 'mac': 0.33; 'skip:# 10': 0.33; 'skip:t 40': 0.33; 'comment': 0.34; 'sense': 0.34; 'skip:_ 10': 0.34; 'skip:d 20': 0.34; 'could': 0.34; 'problem': 0.35; 'here': 0.66; 'between': 0.67; 'results': 0.69; 'url:info': 0.73; '2015': 0.84; 'irrelevant': 0.84; 'route': 0.84; 'subject:base': 0.84; 'url:log': 0.84; 'utilized': 0.84; 'angel': 0.91; 'careful': 0.91; 'destination': 0.91; 'resolved.': 0.91; 'subject:results': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=P9CAL8OSaOlNLaHEBSC808HMoObDg1KaSBB9sIpoUUs=; b=pxY4+oHWzUynSn/+OrnsdTnJwsai/Z/3nMZBuQD32m4vwS2BxnskoJ7JaVn4Xlfzxl GCOr9My8zffjNj44rR1ma9ZRF8pfbhftnfNjomMJt/oh9e+PcQY0hWXW6EAr4HeIIijQ SGH5MaENVyL9uXVl9qQnbM2UEPO79DIVc0yBfTxPwjjznbMd+ZRq51/getZ7MYnRFbxf uEFKQaBAYpHxhafjUJ5meYdOwBgC1VYuZKPKeJFiygxVr52kJMTE0EuRroAK92jDKOyF QhY9IPQJlewPtsOTExwWc5abYl0C/Xg7KSxUfzeJNF1Dhw9wi57RR5dMV6RoqK3/4Elo nDxg==
MIME-Version 1.0
X-Received by 10.107.15.129 with SMTP id 1mr3042769iop.20.1431173285234; Sat, 09 May 2015 05:08:05 -0700 (PDT)
In-Reply-To <554DF14B.6020604@davea.name>
References <CANPUzQ1QJrg7GKRTpfvKLivG+vbNAY+gYeBSsB_zrJmX=4tRFQ@mail.gmail.com> <mikbn3$tc3$1@ger.gmane.org> <CANPUzQ0vTW6a+Umd6nXUOQ+Uds9dhHO-i44EVuAr0hYgcADv0Q@mail.gmail.com> <554DF14B.6020604@davea.name>
Date Sat, 9 May 2015 17:08:05 +0500
Subject Re: calling base class method fetches no results
From david jhon <djhon9813@gmail.com>
To Dave Angel <davea@davea.name>
Cc python-list@python.org
Content-Type multipart/alternative; boundary=001a113e94b2474db70515a4ff04
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.281.1431173294.12865.python-list@python.org> (permalink)
Lines 925
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1431173294 news.xs4all.nl 2908 [2001:888:2000:d::a6]:60955
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90272

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

I am really sorry for any inconvenience caused, I was trying to fix this
bug from last 2 days so I had to post it here. It now has been resolved.
Thanks a lot for your time. I'll be careful again. Have a great weekend!

On Sat, May 9, 2015 at 4:36 PM, Dave Angel <davea@davea.name> wrote:

> On 05/09/2015 03:59 AM, david jhon wrote:
>
>> Hi, I am sorry for sending in five attachments, I cloned the code from
>> here
>> <https://bitbucket.org/msharif/hedera/src>: Let me explain it here:
>>
>>
> Please don't top-post.  Your earlier problem description, which I could
> make no sense of, is now located after your later "clarification".
>
> Thanks for eliminating the attachments.  Many cannot see them.  And for
> extracting only part of the code into the message.  It's still too much for
> me, but others may manage it okay.  To me, it seems likely that most of
> that code will not have any part in the problem you're describing. And in
> some places you have code that's missing its context.
>
> Now, eliminate the pieces of code that are irrelevant to your question,
> and state the problem in terms that make sense.  Somebody is instantiating
> an object.  Exactly which class is being used for that? Somebody else is
> calling a particular method (be specific, rather than just saying "some
> method"), and it's giving the wrong results.  And apparently, those wrong
> results depend on which source file something happens in.
>
>
>
>  Routing Base class defined in DCRouting.py:
>>
>> import logging
>> from copy import copy
>>
>> class Routing(object):
>>      '''Base class for data center network routing.
>>
>>      Routing engines must implement the get_route() method.
>>      '''
>>
>>      def __init__(self, topo):
>>          '''Create Routing object.
>>
>>          @param topo Topo object from Net parent
>>          '''
>>          self.topo = topo
>>
>>      def get_route(self, src, dst, hash_):
>>          '''Return flow path.
>>
>>          @param src source host
>>          @param dst destination host
>>          @param hash_ hash value
>>
>>          @return flow_path list of DPIDs to traverse (including hosts)
>>          '''
>>          raise NotImplementedError
>>
>>      def routes(self, src, dst):
>>          ''' Return list of paths
>>
>>          Only works for Fat-Tree topology
>>
>>          @ param src source host
>>          @ param dst destination host
>>
>>          @ return list of DPIDs (including inputs)
>>          '''
>>
>>          complete_paths = [] # List of complete dpid routes
>>
>>          src_paths = { src : [[src]] }
>>          dst_paths = { dst : [[dst]] }
>>
>>          dst_layer = self.topo.layer(dst)
>>          src_layer = self.topo.layer(src)
>>
>>          lower_layer = src_layer
>>          if dst_layer > src_layer:
>>              lower_layer = dst_layer
>>
>>
>>          for front_layer in range(lower_layer-1, -1, -1):
>>              if src_layer > front_layer:
>>              # expand src frontier
>>                  new_src_paths = {}
>>                  for node in sorted(src_paths):
>>                      path_list = src_paths[node]
>>                      for path in path_list:
>>                          last_node = path[-1]
>>                          for frontier_node in
>> self.topo.upper_nodes(last_node):
>>                              new_src_paths[frontier_node] = [path +
>> [frontier_node]]
>>
>>                              if frontier_node in dst_paths:
>>                                  dst_path_list = dst_paths[frontier_node]
>>                                  for dst_path in dst_path_list:
>>                                      dst_path_copy = copy ( dst_path )
>>                                      dst_path_copy.reverse()
>>                                      complete_paths.append( path +
>> dst_path_copy)
>>                  src_paths = new_src_paths
>>
>>              if dst_layer > front_layer:
>>              # expand dst frontier
>>                  new_dst_paths = {}
>>                  for node in sorted(dst_paths):
>>                      path_list = dst_paths[node]
>>                      for path in path_list:
>>                          last_node = path[-1]
>>                          for frontier_node in
>> self.topo.upper_nodes(last_node):
>>                              new_dst_paths[frontier_node] = [ path +
>> [frontier_node]]
>>
>>                              if frontier_node in src_paths:
>>                                  src_path_list = src_paths[frontier_node]
>>                                  dst_path_copy = copy( path )
>>                                  dst_path_copy.reverse()
>>                                  for src_path in src_path_list:
>>                                      complete_paths.append( src_path +
>> dst_path_copy)
>>
>>                  dst_paths = new_dst_paths
>>
>>              if complete_paths:
>>                  return complete_paths
>> class HashedRouting(Routing):
>>      ''' Hashed routing '''
>>
>>      def __init__(self, topo):
>>          self.topo = topo
>>
>>      def get_route(self, src, dst, hash_):
>>          ''' Return flow path. '''
>>
>>          if src == dst:
>>              return [src]
>>
>>          paths = self.routes(src,dst)
>>          if paths:
>>              #print 'hash_:', hash_
>>              choice = hash_ % len(paths)
>>              #print 'choice:', choice
>>              path = sorted(paths)[choice]
>>              #print 'path:', path
>>              return path
>>
>> ============>
>> Instantiated in util.py:
>>
>> from DCTopo import FatTreeTopo
>> from mininet.util import makeNumeric
>> from DCRouting import HashedRouting, Routing
>>
>> TOPOS = {'ft': FatTreeTopo}
>> ROUTING = {'ECMP' : HashedRouting}
>>
>>
>> def buildTopo(topo):
>>      topo_name, topo_param = topo.split( ',' )
>>      return TOPOS[topo_name](makeNumeric(topo_param))
>>
>>
>> def getRouting(routing, topo):
>>      return ROUTING[routing](topo)
>>
>
> A comment on that last line that says it instantiates the child class
> would have been very helpful.
>
> But even though I can now search for calls to that function, I still
> cannot make sense out of that context, either.
>
>
>
>> ============================> utilized in HController. py:
>> A Piece of code which works with self.r.routes() method:
>> Following list of methods are defined in HController.py
>>
>>      def _ecmp_hash(self, packet):
>>          ''' Return an ECMP-style 5-tuple hash for TCP/IP packets,
>> otherwise
>> 0.
>>          RFC2992 '''
>>          hash_input = [0] * 5
>>          if isinstance(packet.next, ipv4):
>>              ip = packet.next
>>              hash_input[0] = ip.srcip.toUnsigned()
>>              hash_input[1] = ip.dstip.toUnsigned()
>>              hash_input[2] = ip.protocol
>>              if isinstance(ip.next, tcp) or isinstance(ip.next, udp):
>>                  l4 = ip.next
>>                  hash_input[3] = l4.srcport
>>                  hash_input[4] = l4.dstport
>>                  return crc32(pack('LLHHH', *hash_input))
>>          return 0
>>
>>      def _install_reactive_path(self, event, out_dpid, final_out_port,
>> packet):
>>          ''' Install entries on route between two switches. '''
>>          in_name = self.t.node_gen(dpid = event.dpid).name_str()
>>          out_name = self.t.node_gen(dpid = out_dpid).name_str()
>>          hash_ = self._ecmp_hash(packet)
>>          paths = self.r.routes(src_name, dst_name)
>>          if paths == None:
>>               print "PATH is None :("
>>               return
>>          route = self.r.get_route(in_name, out_name, hash_)
>>          print "Route:",route
>>          print '-'*80
>>          if route == None:
>>              print None, "route between", in_name, "and", out_name
>>              return
>>
>>          match = of.ofp_match.from_packet(packet)
>>
>>          for i, node in enumerate(route):
>>              node_dpid = self.t.node_gen(name = node).dpid
>>              if i < len(route) - 1:
>>                  next_node = route[i + 1]
>>                  out_port, next_in_port = self.t.port(node, next_node)
>>              else:
>>                  out_port = final_out_port
>>              self.switches[node_dpid].install(out_port, match,
>> idle_timeout
>> = 10)
>>
>>          if isinstance(packet.next, of.ipv4) and
>> isinstance(packet.next.next, of.tcp):
>>              self.matchDict[(packet.next.srcip, packet.next.dstip,
>> packet.next.next.srcport, packet.next.next.dstport)] = (route, match)
>>
>>      def _handle_PacketIn(self, event):
>>          if not self.all_switches_up:
>>              #log.info("Saw PacketIn before all switches were up -
>> ignoring." )
>>              return
>>
>>          packet = event.parsed
>>          dpid = event.dpid
>>          in_port = event.port
>>
>>          # Learn MAC address of the sender on every packet-in.
>>          self.macTable[packet.src] = (dpid, in_port)
>>          sw_name = self.t.node_gen(dpid = dpid).name_str()
>>          #print "Sw:", sw_name, packet.src, packet.dst,"port", in_port,
>> packet.dst.isMulticast(),"macTable", packet.dst in self.macTable
>>          #print '-'*80
>>
>>          # Insert flow, deliver packet directly to destination.
>>
>>          if packet.dst in self.macTable:
>>              out_dpid, out_port = self.macTable[packet.dst]
>>              self._install_reactive_path(event, out_dpid, out_port,
>> packet)
>>
>>              self.switches[out_dpid].send_packet_data(out_port,
>> event.data)
>>
>>          else:
>>              self._flood(event)
>>
>> ===================> code snippet which returns 'None' number of paths.
>>      def _GlobalFirstFit(self,flow):
>>          '''do the Hedera global first fit here'''
>>          src_name = self.t.node_gen(dpid = flow['src']).name_str()
>>          dst_name = self.t.node_gen(dpid = flow['dst']).name_str()
>>          print 'Global Fisrt Fit for the elephant flow from
>> ',src_name,'to',
>> dst_name
>>          paths = self.r.routes(src_name,dst_name)
>>          print 'all routes found for the big flow:\n',paths
>>          GFF_route = None
>>          if paths == None:
>>             return
>>          else:
>>            for path in paths:
>>              fitCheck = True
>>
>>              for i in range(1,len(path)):
>>                  fitCheck = False
>>                  if self.bwReservation.has_key(path[i-1]) and
>> self.bwReservation[path[i-1]].has_key(path[i]):
>>                      if
>> self.bwReservation[path[i-1]][path[i]]['reserveDemand'] + flow['demand'] >
>> 1 :
>>                          break
>>                      else:
>>
>> #self.bwReservation[path[i-1]][path[i]]['reserveDemand'] += flow['demand']
>>                          fitCheck = True
>>                  else:
>>                      self.bwReservation[path[i-1]]={}
>>
>> self.bwReservation[path[i-1]][path[i]]={'reserveDemand':0}
>>                      fitCheck = True
>>              if fitCheck == True:
>>                  for i in range(1,len(path)):
>>
>>  self.bwReservation[path[i-1]][path[i]]['reserveDemand']
>> += flow['demand']
>>                  GFF_route = path
>>                  print "GFF route found:", path
>>                  break
>>          if GFF_route != None:
>>              """install new GFF_path between source and destintaion"""
>>              self. _install_GFF_path(GFF_route,flow['match'])
>>
>> def launch(topo = None, routing = None, bw = None ):
>>      #print topo
>>      if not topo:
>>          raise Exception ("Please specify the topology")
>>      else:
>>          t = buildTopo(topo)
>>
>>      r = getRouting(routing, t)
>>      if bw == None:
>>          bw = 10.0 #Mb/s
>>          bw = float(bw/1000) #Gb/s
>>      else:
>>          bw = float(bw)/1000
>>      core.registerNew(HController, t, r, bw)
>>      log.info("** HController is running
>>
>> I am really sorry for any inconvenience caused. I, ve tried to make it a
>> bit clear here. I am not even able to debug the code by setting a python
>> debugging point pdb. I need help from you guys. Thanks a lot again for
>> your
>> time and help.
>>
>> Best Regards,
>> David
>>
>>
>> On Sat, May 9, 2015 at 12:07 PM, Mark Lawrence <breamoreboy@yahoo.co.uk>
>> wrote:
>>
>>  On 09/05/2015 07:41, david jhon wrote:
>>>
>>>  Hello everyone,
>>>>
>>>> I am new to python and trying to run an example code from mininet tests.
>>>> Basically, I am trying to call a method in Hcontroller.py from base
>>>> class
>>>> Routing defined in DCRouting.py which runs and fetches all the required
>>>> results in install_reactive_path() method, but it returns None when it
>>>> is
>>>> called from _GlobalFirstFit. I hope someone here could help me fix this
>>>> bug..
>>>>
>>>> I am attaching all the three files(DCRouting.py, HController.py,
>>>> util.py)
>>>> to have a look into. Thanks in advance for your time, help or
>>>> suggestion.
>>>> Thanks a lot!
>>>>
>>>> kind regards,
>>>> David
>>>>
>>>>
>>>>  I'm sorry but I'm not wading through nearly 30kb of code in five
>>> attachments.  Please see http://sscce.org/ for how to put your question
>>> so you're more likely to get answers.
>>>
>>> --
>>> My fellow Pythonistas, ask not what our language can do for you, ask
>>> what you can do for our language.
>>>
>>> Mark Lawrence
>>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>>
>>
>>
>
> --
> DaveA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: calling base class method fetches no results david jhon <djhon9813@gmail.com> - 2015-05-09 17:08 +0500

csiph-web