Exemplo n.º 1
0
    def __init__(self, dev, mode=None, **kwargs):
        """
        :param str mode: Can be used *only* when creating Config object using
                         context manager

            * "private" - Work in private database
            * "dynamic" - Work in dynamic database
            * "batch" - Work in batch database
            * "exclusive" - Work with Locking the candidate configuration
            * "ephemeral" - Work in default/specified ephemeral instance

        :param str ephemeral_instance: ephemeral instance name

        .. code-block:: python

           # mode can be private/dynamic/exclusive/batch/ephemeral
           with Config(dev, mode='exclusive') as cu:
               cu.load('set system services netconf traceoptions file xyz',
                       format='set')
               print cu.diff()
               cu.commit()

        .. warning::
            Ephemeral databases are an advanced Junos feature which
            if used incorrectly can have serious negative impact on the operation
            of the Junos device. We recommend you consult JTAC and/or you Juniper
            account team before deploying the ephemeral database feature in your
            network.
        """
        self.mode = mode
        if not kwargs.get("ephemeral_instance") and kwargs:
            raise ValueError("Unsupported argument provided to Config class")
        self.kwargs = kwargs

        Util.__init__(self, dev=dev)
Exemplo n.º 2
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = []
     if "junos_info" in dev.facts and dev.facts["junos_info"] is not None:
         self._RE_list = list(dev.facts["junos_info"].keys())
     else:
         self._RE_list = [
             x for x in dev.facts.keys() if x.startswith("version_RE")
         ]
     self._multi_RE = bool(dev.facts.get("2RE"))
     # Branch SRX in an SRX cluster doesn't really support multi_RE
     # functionality for SW.
     if (dev.facts.get("personality", "") == "SRX_BRANCH"
             and dev.facts.get("srx_cluster") is True):
         self._multi_RE = False
     self._multi_VC = bool(self._multi_RE is True
                           and dev.facts.get("vc_capable") is True
                           and dev.facts.get("vc_mode") != "Disabled")
     self._mixed_VC = bool(dev.facts.get("vc_mode") == "Mixed")
     # The devices which currently support single-RE ISSU, communicate with
     #  the new Junos VM using internal IP 128.0.0.63.
     # Therefore, the 'localre' value in the 'current_re' fact can currently
     # be used to check for this capability.
     # {master: 0}
     #  user @ s0 > file show / etc / hosts.junos | match localre
     #  128.0.0.63               localre
     self._single_re_issu = bool("current_re" in dev.facts
                                 and "localre" in dev.facts["current_re"])
     self.log = lambda report: None
Exemplo n.º 3
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = []
     if 'junos_info' in dev.facts and dev.facts['junos_info'] is not None:
         self._RE_list = list(dev.facts['junos_info'].keys())
     else:
         self._RE_list = [
             x for x in dev.facts.keys() if x.startswith('version_RE')
         ]
     self._multi_RE = bool(dev.facts.get('2RE'))
     self._vmhost = bool(dev.facts.get('vmhost'))
     # Branch SRX in an SRX cluster doesn't really support multi_RE
     # functionality for SW.
     if (dev.facts.get('personality', '') == 'SRX_BRANCH'
             and dev.facts.get('srx_cluster') is True):
         self._multi_RE = False
     self._multi_VC = bool(self._multi_RE is True
                           and dev.facts.get('vc_capable') is True
                           and dev.facts.get('vc_mode') != 'Disabled')
     self._mixed_VC = bool(dev.facts.get('vc_mode') == 'Mixed')
     # The devices which currently support single-RE ISSU, communicate with
     #  the new Junos VM using internal IP 128.0.0.63.
     # Therefore, the 'localre' value in the 'current_re' fact can currently
     # be used to check for this capability.
     # {master: 0}
     #  user @ s0 > file show / etc / hosts.junos | match localre
     #  128.0.0.63               localre
     if dev.facts['current_re'] is not None:
         self._single_re_issu = bool(
             'current_re' in dev.facts
             and 'localre' in dev.facts['current_re'])
     else:
         self._single_re_issu = bool('current_re' in dev.facts)
     self.log = lambda report: None
Exemplo n.º 4
0
    def __init__(self, dev, mode=None, **kwargs):
        """
        :param str mode: Can be used *only* when creating Config object using
                         context manager

            * "private" - Work in private database
            * "dynamic" - Work in dynamic database
            * "batch" - Work in batch database
            * "exclusive" - Work with Locking the candidate configuration
            * "ephemeral" - Work in default/specified ephemeral instance

        :param str ephemeral_instance: ephemeral instance name

        .. code-block:: python

           # mode can be private/dynamic/exclusive/batch/ephemeral
           with Config(dev, mode='exclusive') as cu:
               cu.load('set system services netconf traceoptions file xyz',
                       format='set')
               print cu.diff()
               cu.commit()

        .. warning:: Ephemeral databases are an advanced Junos feature which
        if used incorrectly can have serious negative impact on the operation
        of the Junos device. We recommend you consult JTAC and/or you Juniper
        account team before deploying the ephemeral database feature in your
        network.
        """
        self.mode = mode
        if not kwargs.get('ephemeral_instance') and kwargs:
            raise ValueError('Unsupported argument provided to Config class')
        self.kwargs = kwargs

        Util.__init__(self, dev=dev)
Exemplo n.º 5
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = []
     if 'junos_info' in dev.facts and dev.facts['junos_info'] is not None:
         self._RE_list = list(dev.facts['junos_info'].keys())
     else:
         self._RE_list = [x for x in dev.facts.keys()
                          if x.startswith('version_RE')]
     self._multi_RE = bool(dev.facts.get('2RE'))
     # Branch SRX in an SRX cluster doesn't really support multi_RE
     # functionality for SW.
     if (dev.facts.get('personality', '') == 'SRX_BRANCH' and
         dev.facts.get('srx_cluster') is True):
         self._multi_RE = False
     self._multi_VC = bool(
         self._multi_RE is True and dev.facts.get('vc_capable') is True and
         dev.facts.get('vc_mode') != 'Disabled')
     self._mixed_VC = bool(dev.facts.get('vc_mode') == 'Mixed')
     # The devices which currently support single-RE ISSU, communicate with
     #  the new Junos VM using internal IP 128.0.0.63.
     # Therefore, the 'localre' value in the 'current_re' fact can currently
     # be used to check for this capability.
     # {master: 0}
     #  user @ s0 > file show / etc / hosts.junos | match localre
     #  128.0.0.63               localre
     self._single_re_issu = bool('current_re' in dev.facts and
                                 'localre' in dev.facts['current_re'])
     self.log = lambda report: None
Exemplo n.º 6
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._RE_list = [
         x for x in dev.facts.keys() if x.startswith('version_RE')]
     self._multi_RE = bool(len(self._RE_list) > 1)
     self._multi_VC = bool(
         self._multi_RE is True and dev.facts.get('vc_capable') is True)
Exemplo n.º 7
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._RE_list = [
         x for x in dev.facts.keys() if x.startswith('version_RE')]
     self._multi_RE = bool(len(self._RE_list) > 1)
     self._multi_VC = bool(
         self._multi_RE is True and dev.facts.get('vc_capable') is True)
Exemplo n.º 8
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = [x for x in dev.facts.keys() if x.startswith("version_RE")]
     self._multi_RE = bool(len(self._RE_list) > 1)
     self._multi_VC = bool(self._multi_RE is True and dev.facts.get("vc_capable") is True)
     self._mixed_VC = bool(dev.facts.get("vc_mode") == "Mixed")
Exemplo n.º 9
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = [
         x for x in dev.facts.keys() if x.startswith('version_RE')]
     self._multi_RE = bool(len(self._RE_list) > 1)
     self._multi_VC = bool(
         self._multi_RE is True and dev.facts.get('vc_capable') is True and
         dev.facts.get('vc_mode') != 'Disabled')
     self._mixed_VC = bool(dev.facts.get('vc_mode') == 'Mixed')
Exemplo n.º 10
0
 def __init__(self, dev):
     Util.__init__(self, dev)
     self._dev = dev
     self._RE_list = []
     if 'junos_info' in dev.facts and dev.facts['junos_info'] is not None:
         self._RE_list = list(dev.facts['junos_info'].keys())
     else:
         self._RE_list = [x for x in dev.facts.keys()
                          if x.startswith('version_RE')]
     self._multi_RE = bool(dev.facts.get('2RE'))
     self._multi_VC = bool(
         self._multi_RE is True and dev.facts.get('vc_capable') is True and
         dev.facts.get('vc_mode') != 'Disabled')
     self._mixed_VC = bool(dev.facts.get('vc_mode') == 'Mixed')
     self.log = lambda report: None
Exemplo n.º 11
0
 def setUp(self, mock_connect):
     self.dev = Device(host='1.1.1.1',
                       user='******',
                       password='******',
                       gather_facts=False)
     self.dev.open()
     self.util = Util(self.dev)
Exemplo n.º 12
0
    def __init__(self, dev, mode=None):
        """
        :param str mode: Can be used *only* when creating Config object using context manager

            * "private" - Work in private database
            * "dynamic" - Work in dynamic database
            * "batch" - Work in batch database
            * "exclusive" - Work with Locking the candidate configuration

            Example::

                # mode can be private/dynamic/exclusive/batch
                with Config(dev, mode='exclusive') as cu:
                    cu.load('set system services netconf traceoptions file xyz', format='set')
                    print cu.diff()
                    cu.commit()
        """
        self.mode = mode
        Util.__init__(self, dev=dev)
Exemplo n.º 13
0
    def __init__(self, dev, mode=None):
        """
        :param str mode: Can be used *only* when creating Config object using context manager

            * "private" - Work in private database
            * "dynamic" - Work in dynamic database
            * "batch" - Work in batch database
            * "exclusive" - Work with Locking the candidate configuration

            Example::

                # mode can be private/dynamic/exclusive/batch
                with Config(dev, mode='exclusive') as cu:
                    cu.load('set system services netconf traceoptions file xyz', format='set')
                    print cu.diff()
                    cu.commit()
        """
        self.mode = mode
        Util.__init__(self, dev=dev)
Exemplo n.º 14
0
 def setUp(self, mock_connect):
     self.dev = Device(
         host="1.1.1.1", user="******", password="******", gather_facts=False
     )
     self.dev.open()
     self.util = Util(self.dev)
Exemplo n.º 15
0
 def __init__(self, dev):
     Util.__init__(self, dev)