@@ -314,13 +314,13 @@ def _parent_xpath(self):
314314 if self .parent is None :
315315 return ""
316316 else :
317- return self .parent ._build_xpath (self .ROOT )
317+ return self .parent ._build_xpath (self .ROOT , None )
318318
319- def _build_xpath (self , root ):
319+ def _build_xpath (self , root , vsys ):
320320 if self .parent is None :
321321 # self with no parent
322322 return ""
323- parent_xpath = self .parent ._build_xpath (root ) + self .XPATH
323+ parent_xpath = self .parent ._build_xpath (root , vsys ) + self .XPATH
324324 if self .SUFFIX is not None :
325325 parent_xpath += self .SUFFIX % (self .uid , )
326326 return parent_xpath
@@ -334,9 +334,12 @@ def xpath_panorama(self):
334334 return self .parent .xpath_panorama ()
335335
336336 def _root_xpath_vsys (self , vsys ):
337- root_xpath = "/config/devices/entry[@name='localhost.localdomain']/vsys"
338- specific_vsys = "/entry[@name='{0}']" .format (vsys ) if vsys else ""
339- return root_xpath + specific_vsys
337+ if vsys == 'shared' :
338+ return '/config/shared'
339+
340+ xpath = "/config/devices/entry[@name='localhost.localdomain']"
341+ xpath += "/vsys/entry[@name='{0}']" .format (vsys or 'vsys1' )
342+ return xpath
340343
341344 def element (self , with_children = True , comparable = False ):
342345 """Construct an ElementTree for this PanObject and all its children
@@ -1441,8 +1444,7 @@ def _about_parameter(self, parameter):
14411444 return ans
14421445
14431446 def _requires_import_consideration (self ):
1444- if self .vsys in (None , 'shared' ) or not hasattr (self ,
1445- 'xpath_import_base' ):
1447+ if self .vsys == 'shared' or not hasattr (self , 'XPATH_IMPORT' ):
14461448 return False
14471449 return True
14481450
@@ -1489,9 +1491,12 @@ def _gather_bulk_info(self, func=None):
14891491 for node in itertools .chain (all_objects ):
14901492 all_objects .extend (node .children )
14911493 if node ._requires_import_consideration ():
1492- vsys_dict .setdefault (node .vsys , {})
1493- vsys_dict [node .vsys ].setdefault (node .xpath_import_base (), [])
1494- vsys_dict [node .vsys ][node .xpath_import_base ()].append (node )
1494+ vsys = node .vsys
1495+ if vsys is None and node .ALWAYS_IMPORT :
1496+ vsys = 'vsys1'
1497+ vsys_dict .setdefault (vsys , {})
1498+ vsys_dict [vsys ].setdefault (node .xpath_import_base (), [])
1499+ vsys_dict [vsys ][node .xpath_import_base ()].append (node )
14951500
14961501 return dev , instances , vsys_dict
14971502
@@ -2965,7 +2970,7 @@ def create_from_device(cls,
29652970 system_info = device .refresh_system_info ()
29662971 version = system_info [0 ]
29672972 model = system_info [1 ]
2968- if model == "Panorama" :
2973+ if model == "Panorama" or model . startswith ( 'M-' ) :
29692974 instance = panorama .Panorama (hostname ,
29702975 api_username ,
29712976 api_password ,
@@ -3271,14 +3276,14 @@ def set_config_changed(self, scope=None):
32713276 if scope not in self .config_changed :
32723277 self .config_changed .append (scope )
32733278
3274- def _build_xpath (self , root ):
3275- return self .xpath_root (root )
3279+ def _build_xpath (self , root , vsys ):
3280+ return self .xpath_root (root , vsys or self . vsys )
32763281
3277- def xpath_root (self , root_type ):
3282+ def xpath_root (self , root_type , vsys ):
32783283 if root_type == Root .DEVICE :
32793284 xpath = self .xpath_device ()
32803285 elif root_type == Root .VSYS :
3281- xpath = self .xpath_vsys ( )
3286+ xpath = self ._root_xpath_vsys ( vsys )
32823287 elif root_type == Root .MGTCONFIG :
32833288 xpath = self .xpath_mgtconfig ()
32843289 elif root_type == Root .PANORAMA :
0 commit comments