Resolve merge conflicts

This commit is contained in:
rajvidhimar 2017-03-06 14:11:26 +05:30
commit a06d5e961d
4 changed files with 60 additions and 55 deletions

View File

@ -10,6 +10,7 @@ addons:
- python-dev - python-dev
install: install:
<<<<<<< HEAD
- if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install importlib; fi - if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install importlib; fi
- "pip install junos-eznc" - "pip install junos-eznc"
- "pip install jxmlease" - "pip install jxmlease"
@ -18,3 +19,22 @@ install:
- "pip install nose" - "pip install nose"
script: nosetests -v tests/unit/modules/junos_test.py script: nosetests -v tests/unit/modules/junos_test.py
=======
- pip install -r requirements/zeromq.txt -r requirements/cloud.txt
- pip install --allow-all-external -r requirements/opt.txt
before_script:
- "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pylint --rcfile=.testing.pylintrc salt/ && echo 'Finished Pylint Check Cleanly' || echo 'Finished Pylint Check With Errors'"
- "/home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/pep8 --ignore=E501,E12 salt/ && echo 'Finished PEP-8 Check Cleanly' || echo 'Finished PEP-8 Check With Errors'"
script: "sudo -E /home/travis/virtualenv/python${TRAVIS_PYTHON_VERSION}/bin/python setup.py test --runtests-opts='--run-destructive --sysinfo -v --coverage'"
after_success:
- coveralls
notifications:
irc:
channels: "irc.freenode.org#salt-devel"
on_success: change
on_failure: change
>>>>>>> bdc8d2d196417a4ce9247d5ea9a9770ab5d1adae

View File

@ -48,7 +48,7 @@ def defaults():
def facts(proxy=None): def facts(proxy=None):
if proxy is None or proxy['junos.initialized']() is False: if proxy is None or proxy['junos.initialized']() is False:
return {} return {}
return {'junos_facts': proxy['junos.grains']()} return {'junos_facts': proxy['junos.get_serialized_facts']()}
def os_family(): def os_family():

View File

@ -77,16 +77,7 @@ def facts_refresh():
except Exception as exception: except Exception as exception:
ret['message'] = 'Execution failed due to "{0}"'.format(exception) ret['message'] = 'Execution failed due to "{0}"'.format(exception)
ret['out'] = False ret['out'] = False
ret['facts'] = dict(conn.facts) ret['facts'] = __proxy__['junos.get_serialized_facts']()
ret['facts']['version_info'] = \
dict(ret['facts']['version_info'])
# For backward compatibility. 'junos_info' is present
# only of in newer versions of facts.
if 'junos_info' in ret['facts']:
ret['facts']['junos_info']['re0']['object'] = \
dict(ret['facts']['junos_info']['re0']['object'])
ret['facts']['junos_info']['re1']['object'] = \
dict(ret['facts']['junos_info']['re1']['object'])
try: try:
__salt__['saltutil.sync_grains']() __salt__['saltutil.sync_grains']()
@ -107,19 +98,9 @@ def facts():
salt 'device_name' junos.facts salt 'device_name' junos.facts
''' '''
conn = __proxy__['junos.conn']()
ret = dict() ret = dict()
try: try:
ret['facts'] = dict(conn.facts) ret['facts'] = __proxy__['junos.get_serialized_facts']()
ret['facts']['version_info'] = \
dict(ret['facts']['version_info'])
# For backward compatibility. 'junos_info' is present
# only of in newer versions of facts.
if 'junos_info' in ret['facts']:
ret['facts']['junos_info']['re0']['object'] = \
dict(ret['facts']['junos_info']['re0']['object'])
ret['facts']['junos_info']['re1']['object'] = \
dict(ret['facts']['junos_info']['re1']['object'])
ret['out'] = True ret['out'] = True
except Exception as exception: except Exception as exception:
ret['message'] = 'Could not display facts due to "{0}"'.format( ret['message'] = 'Could not display facts due to "{0}"'.format(
@ -157,7 +138,7 @@ def rpc(cmd=None, dest=None, format='xml', **kwargs):
The format in which the rpc reply is received from the device. The format in which the rpc reply is received from the device.
(default = xml) (default = xml)
* kwargs: keyworded arguments taken by rpc call like- * kwargs: keyworded arguments taken by rpc call like-
* timeout: * dev_timeout:
Set NETCONF RPC timeout. Can be used for commands which Set NETCONF RPC timeout. Can be used for commands which
take a while to execute. (default= 30 seconds) take a while to execute. (default= 30 seconds)
* filter: * filter:
@ -400,8 +381,8 @@ def commit(**kwargs):
except Exception as exception: except Exception as exception:
ret['out'] = False ret['out'] = False
ret['message'] = \ ret['message'] = \
'Commit check succeeded but actual commit failed with "{0}"'\ 'Commit check succeeded but actual commit failed with "{0}"' \
.format(exception) .format(exception)
else: else:
ret['out'] = False ret['out'] = False
ret['message'] = 'Pre-commit check failed.' ret['message'] = 'Pre-commit check failed.'
@ -424,7 +405,7 @@ def rollback(id=0, **kwargs):
* id: * id:
The rollback id value [0-49]. (default = 0) The rollback id value [0-49]. (default = 0)
* kwargs: Keyworded arguments which can be provided like- * kwargs: Keyworded arguments which can be provided like-
* timeout: * dev_timeout:
Set NETCONF RPC timeout. Can be used for commands which Set NETCONF RPC timeout. Can be used for commands which
take a while to execute. (default = 30 seconds) take a while to execute. (default = 30 seconds)
* comment: * comment:
@ -440,7 +421,7 @@ def rollback(id=0, **kwargs):
ret = dict() ret = dict()
conn = __proxy__['junos.conn']() conn = __proxy__['junos.conn']()
op = dict() op = dict()
if '__pub_arg' in kwargs: if '__pub_arg' in kwargs:
if kwargs['__pub_arg']: if kwargs['__pub_arg']:
@ -807,7 +788,7 @@ def install_config(path=None, **kwargs):
ret['out'] = True ret['out'] = True
if path is None: if path is None:
ret['message'] =\ ret['message'] = \
'Please provide the salt path where the configuration is present' 'Please provide the salt path where the configuration is present'
ret['out'] = False ret['out'] = False
return ret return ret
@ -817,7 +798,10 @@ def install_config(path=None, **kwargs):
template_vars = kwargs["template_vars"] template_vars = kwargs["template_vars"]
template_cached_path = files.mkstemp() template_cached_path = files.mkstemp()
__salt__['cp.get_template'](path, template_cached_path, template_vars=template_vars) __salt__['cp.get_template'](
path,
template_cached_path,
template_vars=template_vars)
if not os.path.isfile(template_cached_path): if not os.path.isfile(template_cached_path):
ret['message'] = 'Invalid file path.' ret['message'] = 'Invalid file path.'
@ -901,8 +885,13 @@ def install_config(path=None, **kwargs):
check = conn.cu.commit_check() check = conn.cu.commit_check()
except Exception as exception: except Exception as exception:
ret['message'] = \ ret['message'] = \
<<<<<<< HEAD
'Commit check threw the following exception: "{0}"'\ 'Commit check threw the following exception: "{0}"'\
.format(exception) .format(exception)
=======
'Commit check threw the following exception: "{0}"' \
.format(exception)
>>>>>>> bdc8d2d196417a4ce9247d5ea9a9770ab5d1adae
ret['out'] = False ret['out'] = False
return ret return ret
@ -912,8 +901,13 @@ def install_config(path=None, **kwargs):
ret['message'] = 'Successfully loaded and committed!' ret['message'] = 'Successfully loaded and committed!'
except Exception as exception: except Exception as exception:
ret['message'] = \ ret['message'] = \
<<<<<<< HEAD
'Commit check successful but commit failed with "{0}"'\ 'Commit check successful but commit failed with "{0}"'\
.format(exception) .format(exception)
=======
'Commit check successful but commit failed with "{0}"' \
.format(exception)
>>>>>>> bdc8d2d196417a4ce9247d5ea9a9770ab5d1adae
ret['out'] = False ret['out'] = False
return ret return ret
else: else:
@ -1024,9 +1018,9 @@ def install_os(path=None, **kwargs):
try: try:
conn.sw.reboot() conn.sw.reboot()
except Exception as exception: except Exception as exception:
ret['message'] =\ ret['message'] = \
'Installation successful but reboot failed due to : "{0}"'\ 'Installation successful but reboot failed due to : "{0}"' \
.format(exception) .format(exception)
ret['out'] = False ret['out'] = False
return ret return ret
ret['message'] = 'Successfully installed and rebooted!' ret['message'] = 'Successfully installed and rebooted!'
@ -1068,7 +1062,7 @@ def file_copy(src=None, dest=None, **kwargs):
if dest is None: if dest is None:
ret['message'] = \ ret['message'] = \
'Please provide the absolute path of the destination where the file is to be copied.' 'Please provide the absolute path of the destination where the file is to be copied.'
ret['out'] = False ret['out'] = False
return ret return ret

View File

@ -39,7 +39,6 @@ from __future__ import absolute_import
# Import python libs # Import python libs
import logging import logging
import copy
# Import 3rd-party libs # Import 3rd-party libs
try: try:
@ -123,27 +122,19 @@ def proxytype():
''' '''
return 'junos' return 'junos'
def get_serialized_facts():
def grains(): facts = dict(thisproxy['conn'].facts)
if 'version_info' in facts:
thisproxy['grains'] = dict(thisproxy['conn'].facts) facts['version_info'] = \
dict(facts['version_info'])
if thisproxy['grains']: # For backward compatibility. 'junos_info' is present
thisproxy['grains']['version_info'] = dict( # only of in newer versions of facts.
thisproxy['grains']['version_info']) if 'junos_info' in facts:
# For backward compatibility. 'junos_info' is present facts['junos_info']['re0']['object'] = \
# only of in newer versions of facts. dict(facts['junos_info']['re0']['object'])
if 'junos_info' in thisproxy['grains']: facts['junos_info']['re1']['object'] = \
thisproxy['grains']['junos_info']['re0']['object'] = \ dict(facts['junos_info']['re1']['object'])
dict(thisproxy['grains']['junos_info']['re0']['object']) return facts
thisproxy['grains']['junos_info']['re1']['object'] = \
dict(thisproxy['grains']['junos_info']['re1']['object'])
else:
log.debug(
'Grains will not be populated by junos facts \
as the device returned an empty facts dictionary.')
return thisproxy['grains']
def ping(): def ping():
''' '''