Esempio n. 1
0
File: flow.py Progetto: Kent1/nxpy
 def buildChildren(self, child_, nodeName_, from_subclass=False):
     if nodeName_ == 'name':
         name_ = child_.text
         name_ = re.sub(whitespace_pattern, " ", name_).strip()
         self.name = name_
     elif nodeName_ == 'match':
         for grandChild_ in child_:
             grandChildName_ = tag_pattern.match(
                 grandChild_.tag).groups()[-1]
             grandChildText = grandChild_.text
             grandChildText = re.sub(
                 whitespace_pattern, " ", grandChildText).strip()
             self.match[grandChildName_].append(grandChildText)
     elif nodeName_ == 'then':
         for grandChild_ in child_:
             grandChildName_ = tag_pattern.match(
                 grandChild_.tag).groups()[-1]
             self.then[grandChildName_] = True
Esempio n. 2
0
File: unit.py Progetto: Kent1/nxpy
    def buildChildren(self, child_, nodeName_, from_subclass=False):

        if nodeName_ == 'name':
            name_ = child_.text
            name_ = re.sub(whitespace_pattern, " ", name_).strip()
            self.name = name_
        elif nodeName_ == 'vlan-id':
            vlanid_ = child_.text
            vlanid_ = re.sub(whitespace_pattern, " ", vlanid_).strip()
            self.vlan_id = vlanid_
        elif nodeName_ == 'description':
            description_ = child_.text
            description_ = re.sub(
                whitespace_pattern, " ", description_).strip()
            self.description = description_
        elif nodeName_ == 'family':
            vlan_unit_list = []
            family_dict = {}
            for node in child_:
                childName_ = tag_pattern.match(node.tag).groups()[-1]
                # *************** ETHERNET-SWITCHING ****************
                if childName_ == 'ethernet-switching':
                    for grandChild_ in node:
                        grandchildName_ = tag_pattern.match(
                            grandChild_.tag).groups()[-1]
                        if grandchildName_ == 'port-mode':
                            pmode = grandChild_.text
                            pmode = re.sub(
                                whitespace_pattern, " ", pmode).strip()
                            family_dict['port-mode'] = pmode
                        elif grandchildName_ == 'vlan':
                            for vlan_member in grandChild_:
                                vlanmem = vlan_member.text
                                vlanmem = re.sub(
                                    whitespace_pattern, " ", vlanmem).strip()
                                vlan_unit_list.append(vlanmem)
                            family_dict['vlan_members'] = vlan_unit_list
                    self.family.append(family_dict)
Esempio n. 3
0
File: parser.py Progetto: Kent1/nxpy
 def parseString(self):
     '''Normally this would be an rpc_reply in case of netconf invoking or
     a configuration element in case of normal parsing'''
     from StringIO import StringIO
     doc = self.parsexml_(StringIO(self.confile))
     rootNode = doc.getroot()
     rootNodeTag = tag_pattern.match(rootNode.tag).groups()[-1]
     if rootNodeTag == 'rpc-reply':
         rootNode = rootNode.xpath("//*[local-name()='configuration']")[0]
     if rootNodeTag == 'data':
         rootNode = rootNode.xpath("//*[local-name()='configuration']")[0]
     rootObj = Device()
     rootObj.build(rootNode)
     return rootObj
Esempio n. 4
0
File: vlan.py Progetto: Kent1/nxpy
 def build(self, node):
     for child in node:
         nodeName_ = tag_pattern.match(child.tag).groups()[-1]
         self.buildChildren(child, nodeName_)