panos_util/panorama.py
def create_from_element(e: Element) -> Panorama:
        """Create Panorama object from XML element."""
        device_groups = {}

        shared_e = e.find("./shared")
        shared_obj = DeviceGroup.create_from_element(shared_e)
        shared_obj.name = "shared"  # Helps with debugging.
        device_groups.update({"shared": shared_obj})

        for dg_e in e.findall("./devices/entry/device-group/"):
            dg_obj = DeviceGroup.create_from_element(dg_e)
            device_groups.update({dg_obj.name: dg_obj})

        # Properly set parent device group.
        for parent_e in e.findall("./readonly/devices/entry/device-group/entry"):
            dg_name = parent_e.get("name")
            parent_name = parent_e.findtext(".//parent-dg")

            # If no 'parent-dg' element was defined, parent is 'shared'.
            if parent_name is None:
                parent_name = "shared"

            # Get parent object out of DG hash, set reference on current object.
            dg = device_groups.get(dg_name)
            parent_dg = device_groups.get(parent_name)
            dg.parent_dg = parent_dg

        return Panorama(device_groups)
Create Panorama object from XML element.
Create Panorama object from XML element.
Create Panorama object from XML element .
def create_from_element(e: Element) -> Panorama:
        device_groups = {}
        shared_e = e.find("./shared")
        shared_obj = DeviceGroup.create_from_element(shared_e)
        shared_obj.name = "shared"  
        device_groups.update({"shared": shared_obj})
        for dg_e in e.findall("./devices/entry/device-group/"):
            dg_obj = DeviceGroup.create_from_element(dg_e)
            device_groups.update({dg_obj.name: dg_obj})
        for parent_e in e.findall("./readonly/devices/entry/device-group/entry"):
            dg_name = parent_e.get("name")
            parent_name = parent_e.findtext(".//parent-dg")
            if parent_name is None:
                parent_name = "shared"
            dg = device_groups.get(dg_name)
            parent_dg = device_groups.get(parent_name)
            dg.parent_dg = parent_dg
        return Panorama(device_groups)
def create_from_element ( e : Element ) -> Panorama : device_groups = { } shared_e = e . find ( "./shared" ) shared_obj = DeviceGroup . create_from_element ( shared_e ) shared_obj . name = "shared" device_groups . update ( { "shared" : shared_obj } ) for dg_e in e . findall ( "./devices/entry/device-group/" ) : dg_obj = DeviceGroup . create_from_element ( dg_e ) device_groups . update ( { dg_obj . name : dg_obj } ) for parent_e in e . findall ( "./readonly/devices/entry/device-group/entry" ) : dg_name = parent_e . get ( "name" ) parent_name = parent_e . findtext ( ".//parent-dg" ) if parent_name is None : parent_name = "shared" dg = device_groups . get ( dg_name ) parent_dg = device_groups . get ( parent_name ) dg . parent_dg = parent_dg return Panorama ( device_groups )
Create Panorama object from XML element.
Create Panorama object from XML element .
"""Create Panorama object from XML element.""" # Helps with debugging. # Properly set parent device group. # If no 'parent-dg' element was defined, parent is 'shared'. # Get parent object out of DG hash, set reference on current object.
e
Element