Browse code

adds check on config_format kwarg in junos

This adds a check to validate the arugment for config_format kwarg in
get_config. If the specified format is not a valid option, the shared
module will call fail_json

Peter Sprygada authored on 2016/04/24 21:20:14
Showing 1 changed files
... ...
@@ -250,9 +250,12 @@ class Netconf(object):
250 250
         return self.device.facts
251 251
 
252 252
     def get_config(self, config_format="text"):
253
-        ele = self.rpc('get_configuration', format=config_format)
253
+        if config_format not in ['text', 'set', 'xml']:
254
+            msg = 'invalid config format... must be one of xml, text, set'
255
+            self._fail(msg=msg)
254 256
 
255
-        if config_format == "text" or config_format == "set":
257
+        ele = self.rpc('get_configuration', format=config_format)
258
+        if config_format in ['text', 'set']:
256 259
            return str(ele.text).strip()
257 260
         elif config_format == "xml":
258 261
             return ele