Repository: QualiSystems/cloudshell-networking-juniper

Issue:
Vendor and Model attributes sometimes empty
In some cases, vendor and Model attributes are empty during the autoload. For example when sysObjectID = jnxProductQFX520032C32Q.

Comments:

Patch:
diff --git a/.gitignore b/.gitignore
index 4d86431..a1ea7c8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,3 +63,5 @@ target/
 .pypirc
 
 .DS_Store
+
+.idea/
diff --git a/cloudshell/networking/juniper/autoload/juniper_snmp_autoload.py b/cloudshell/networking/juniper/autoload/juniper_snmp_autoload.py
index aea017e..30f6513 100755
--- a/cloudshell/networking/juniper/autoload/juniper_snmp_autoload.py
+++ b/cloudshell/networking/juniper/autoload/juniper_snmp_autoload.py
@@ -294,7 +294,7 @@ class JuniperSnmpAutoload(object):
         model = ''
         os_version = ''
         sys_obj_id = self.snmp_handler.get_property('SNMPv2-MIB', 'sysObjectID', 0)
-        model_search = re.search('^(?P<vendor>\w+)-\S+jnxProductName(?P<model>\S+)', sys_obj_id)
+        model_search = re.search('^(?P<vendor>\w+)-\S+jnxProduct(?:Name)?(?P<model>\S+)', sys_obj_id)
         if model_search:
             vendor = model_search.groupdict()['vendor'].capitalize()
             model = model_search.groupdict()['model']
diff --git a/version.txt b/version.txt
index 2d2d681..30b26df 100644
--- a/version.txt
+++ b/version.txt
@@ -1,1 +1,1 @@
-4.0.10
+4.0.11


Test patch:
diff --git a/tests/networking/juniper/autoload/test_juniper_snmp_autoload.py b/tests/networking/juniper/autoload/test_juniper_snmp_autoload.py
index e80ff56..9d4baa1 100644
--- a/tests/networking/juniper/autoload/test_juniper_snmp_autoload.py
+++ b/tests/networking/juniper/autoload/test_juniper_snmp_autoload.py
@@ -159,6 +159,34 @@ class TestJuniperSnmpAutoload(TestCase):
                  call('SNMPv2-MIB', 'sysLocation', '0')]
         self._snmp_handler.get_property.assert_has_calls(calls)
 
+    def test_build_root2(self):
+        vendor = 'Test_Vendor'
+        model = 'Tets_Model'
+        version = '12.1R6.5'
+        contact_name = Mock()
+        system_name = Mock()
+        location = Mock()
+        self._snmp_handler.get_property.side_effect = [
+            "{0}-testjnxProduct{1}".format(vendor, model),
+            "TEst JUNOS {} #/test".format(version),
+            contact_name,
+            system_name,
+            location
+        ]
+
+        self._autoload_operations_instance._build_root()
+
+        self.assertIs(self._autoload_operations_instance.resource.contact_name, contact_name)
+        self.assertIs(self._autoload_operations_instance.resource.system_name, system_name)
+        self.assertIs(self._autoload_operations_instance.resource.location, location)
+        self.assertEqual(self._resource.os_version, version)
+        self.assertEqual(self._resource.vendor, vendor.capitalize())
+        self.assertEqual(self._resource.model, model)
+        calls = [call('SNMPv2-MIB', 'sysObjectID', 0), call('SNMPv2-MIB', 'sysDescr', '0'),
+                 call('SNMPv2-MIB', 'sysContact', '0'), call('SNMPv2-MIB', 'sysName', '0'),
+                 call('SNMPv2-MIB', 'sysLocation', '0')]
+        self._snmp_handler.get_property.assert_has_calls(calls)
+
     def test_get_content_indexes(self):
         index1 = 1
         index2 = 2