Exemple #1
0
 def create(self):
     if self.parent is None:
         self.create_vsys()
         return
     # This is a firewall under a panorama or devicegroup
     panorama = self.panorama()
     logger.debug(panorama.hostname + ": create called on %s object \"%s\"" % (type(self), self.name))
     panorama.set_config_changed()
     element = self.element_str()
     panorama.xapi.set(self.xpath_short(), element)
Exemple #2
0
 def create(self):
     if self.parent is None:
         self.create_vsys()
         return
     # This is a firewall under a panorama or devicegroup
     panorama = self.panorama()
     logger.debug(panorama.hostname + ": create called on %s object \"%s\"" % (type(self), self.uid))
     panorama.set_config_changed()
     element = self.element_str()
     panorama.xapi.set(self.xpath_short(), element)
Exemple #3
0
 def delete(self):
     if self.parent is None:
         self.delete_vsys()
         return
     panorama = self.panorama()
     logger.debug(panorama.hostname + ": delete called on %s object \"%s\"" % (type(self), self.serial))
     if self.parent == self.devicegroup() and self.multi_vsys:
         # This is a firewall under a devicegroup
         # Refresh device-group first to see if this is the only vsys
         devices_xpath = self.devicegroup().xpath() + self.XPATH
         devices_xml = panorama.xapi.get(devices_xpath)
         dg_vsys = devices_xml.findall("result/devices/entry[@name='%s']/vsys/entry" % self.serial)
         if dg_vsys:
             if len(dg_vsys) == 1:
                 # Only vsys, so delete whole entry
                 panorama.set_config_changed()
                 panorama.xapi.delete(self.xpath())
             else:
                 # It's not the only vsys, just delete the vsys
                 panorama.set_config_changed()
                 panorama.xapi.delete(self.xpath() + "/vsys/entry[@name='%s']" % self.vsys)
     else:
         # This is a firewall under a panorama
         panorama.set_config_changed()
         panorama.xapi.delete(self.xpath())
     if self.parent is not None:
         self.parent.remove_by_name(self.name, type(self))
Exemple #4
0
 def delete(self):
     if self.parent is None:
         self.delete_vsys()
         return
     panorama = self.panorama()
     logger.debug(panorama.hostname +
                  ": delete called on %s object \"%s\"" %
                  (type(self), self.serial))
     if self.parent == self.devicegroup() and self.multi_vsys:
         # This is a firewall under a devicegroup
         # Refresh device-group first to see if this is the only vsys
         devices_xpath = self.devicegroup().xpath() + self.XPATH
         devices_xml = panorama.xapi.get(devices_xpath)
         dg_vsys = devices_xml.findall(
             "result/devices/entry[@name='%s']/vsys/entry" % self.serial)
         if dg_vsys:
             if len(dg_vsys) == 1:
                 # Only vsys, so delete whole entry
                 panorama.set_config_changed()
                 panorama.xapi.delete(self.xpath())
             else:
                 # It's not the only vsys, just delete the vsys
                 panorama.set_config_changed()
                 panorama.xapi.delete(self.xpath() +
                                      "/vsys/entry[@name='%s']" % self.vsys)
     else:
         # This is a firewall under a panorama
         panorama.set_config_changed()
         panorama.xapi.delete(self.xpath())
     if self.parent is not None:
         self.parent.remove_by_name(self.uid, type(self))