Example #1
0
    def address(self):
        """The assigned address of server.

        :getter: :rtype: ``string``
        :setter:
          :param address: address to set.
          :type address: ``string``
          :rtype: ``bool``
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric', 'addr')

        try:
            value = compare_values(values)
        except IncosistentData as exc:
            # haproxy returns address:port and compare_values() may raise
            # IncosistentData exception because assigned port is different
            # per process and not the assigned address.
            # Since we want to report the address, we simply catch that case
            # and report the assigned address.
            addr_across_proc = [value[1].split(':')[0] for value in values]
            if not elements_of_list_same(addr_across_proc):
                raise exc
            else:
                return addr_across_proc[0]
        else:
            return value.split(':')[0]
Example #2
0
    def address(self):
        """The assigned address of server.

        :getter: :rtype: ``string``
        :setter:
          :param address: address to set.
          :type address: ``string``
          :rtype: ``bool``
        """
        values = cmd_across_all_procs(
            self._server_per_proc, 'metric', 'addr'
        )

        try:
            value = compare_values(values)
        except IncosistentData as exc:
            # haproxy returns address:port and compare_values() may raise
            # IncosistentData exception because assigned port is different
            # per process and not the assigned address.
            # Since we want to report the address, we simply catch that case
            # and report the assigned address.
            addr_across_proc = [value[1].split(':')[0] for value in values]
            if not elements_of_list_same(addr_across_proc):
                raise exc
            else:
                return addr_across_proc[0]
        else:
            return value.split(':')[0]
Example #3
0
    def check_code(self):
        """Return the check code.

        :rtype: ``integer``
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric',
                                      'check_code')

        return compare_values(values)
Example #4
0
    def check_status(self):
        """Return the check status.

        :rtype: ``string``
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric',
                                      'check_status')

        return compare_values(values)
Example #5
0
    def last_agent_check(self):
        """Return the last agent check contents or textual error.

        :rtype: ``string``
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric',
                                      'last_agt')

        return compare_values(values)
Example #6
0
    def weight(self):
        """Return the weight.

        :rtype: ``integer``
        :raise: :class:`IncosistentData` exception if weight is different
          per process
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric', 'weight')

        return compare_values(values)
Example #7
0
    def last_agent_check(self):
        """Return the last agent check contents or textual error.

        :rtype: ``string``
        """
        values = cmd_across_all_procs(
            self._server_per_proc, 'metric', 'last_agt'
        )

        return compare_values(values)
Example #8
0
    def check_status(self):
        """Return the check status.

        :rtype: ``string``
        """
        values = cmd_across_all_procs(
            self._server_per_proc, 'metric', 'check_status'
        )

        return compare_values(values)
Example #9
0
    def weight(self):
        """Return the weight.

        :rtype: ``integer``
        :raise: :class:`IncosistentData` exception if weight is different
          per process
        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric', 'weight')

        return compare_values(values)
Example #10
0
    def check_code(self):
        """Return the check code.

        :rtype: ``integer``
        """
        values = cmd_across_all_procs(
            self._server_per_proc, 'metric', 'check_code'
        )

        return compare_values(values)
Example #11
0
    def setaddress(self, new_address):
        """
        Set this server's address.
        :rtype: ``string``
        """

        values = cmd_across_all_procs(self._server_per_proc,
                                      'setaddress',
                                      new_address=str(new_address))

        return compare_values(values)
Example #12
0
    def status(self):
        """Return the status of the server.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process

        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric', 'status')

        return compare_values(values)
Example #13
0
    def status(self):
        """Return the status of the server.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process

        """
        values = cmd_across_all_procs(self._server_per_proc, 'metric', 'status')

        return compare_values(values)
Example #14
0
    def status(self):
        """Return the status of the backend.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process.

        """
        results = cmd_across_all_procs(self._backend_per_proc, 'metric', 'status')

        return compare_values(results)
Example #15
0
    def status(self):
        """Return the status of the backend.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process.

        """
        results = cmd_across_all_procs(self._backend_per_proc, 'metric',
                                       'status')

        return compare_values(results)
Example #16
0
    def setaddress(self, new_address, new_port=None):
        """Set this servers address.

        :param new_address: new ip address of server
        :param new_port: new port of server (optional)

        :rtype: ``string``
        """

        values = cmd_across_all_procs(
            self._server_per_proc, 'setaddress', new_address=str(new_address), new_port=new_port
        )

        return compare_values(values)
Example #17
0
    def nodename(self):
        """Return nodename of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.nodename
          'test.foo.com'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric', 'node')

        return compare_values(values)
Example #18
0
    def description(self):
        """Return description of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.description
          'test'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric',
                                      'description')

        return compare_values(values)
Example #19
0
    def releasedate(self):
        """Return release date of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.releasedate
          '2014/10/31'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric',
                                      'Release_date')

        return compare_values(values)
Example #20
0
    def nodename(self):
        """Return nodename of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.nodename
          'test.foo.com'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric',
                                      'node')

        return compare_values(values)
Example #21
0
    def description(self):
        """Return description of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.description
          'test'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric',
                                      'description')

        return compare_values(values)
Example #22
0
    def releasedate(self):
        """Return release date of HAProxy

        :rtype: ``string``

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.releasedate
          '2014/10/31'
        """
        values = cmd_across_all_procs(self._hap_processes, 'metric',
                                      'Release_date')

        return compare_values(values)
Example #23
0
    def version(self):
        """Return version of HAProxy

        :rtype: ``string``

        Usage::
          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.version
          '1.5.8'
        """
        # If multiple version of HAProxy share the same socket directory
        # then this wil always raise IncosistentData exception.
        # TODO: Document this on README
        values = cmd_across_all_procs(self._hap_processes, 'metric', 'Version')

        return compare_values(values)
Example #24
0
    def version(self):
        """Return version of HAProxy

        :rtype: ``string``

        Usage::
          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> hap.version
          '1.5.8'
        """
        # If multiple version of HAProxy share the same socket directory
        # then this wil always raise IncosistentData exception.
        # TODO: Document this on README
        values = cmd_across_all_procs(self._hap_processes, 'metric', 'Version')

        return compare_values(values)
Example #25
0
    def status(self):
        """Return the status of the frontend.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> frontend = hap.frontend('frontend2_proc34')
          >>> frontend.status
          'OPEN'
        """
        results = cmd_across_all_procs(self._frontend_per_proc, 'metric',
                                       'status')

        return compare_values(results)
Example #26
0
    def status(self):
        """Return the status of the frontend.

        :rtype: ``string``
        :raise: :class:`IncosistentData` exception if status is different
          per process

        Usage::

          >>> from haproxyadmin import haproxy
          >>> hap = haproxy.HAProxy(socket_dir='/run/haproxy')
          >>> frontend = hap.frontend('frontend2_proc34')
          >>> frontend.status
          'OPEN'
        """
        results = cmd_across_all_procs(self._frontend_per_proc, 'metric',
                                       'status')

        return compare_values(results)