How to use the towerlib.entities.core.Entity function in towerlib

To help you get started, we’ve selected a few towerlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github schubergphilis / towerlib / towerlib / entities / instance.py View on Github external
def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)
github schubergphilis / towerlib / towerlib / entities / __init__.py View on Github external
NotificationTwilio,
                                            NotificationEmail,
                                            NotificationSlack)

__author__ = '''Costas Tyfoxylos '''
__docformat__ = '''google'''
__date__ = '''2018-01-02'''
__copyright__ = '''Copyright 2018, Costas Tyfoxylos'''
__license__ = '''MIT'''
__maintainer__ = '''Costas Tyfoxylos'''
__email__ = ''''''
__status__ = '''Development'''  # "Prototype", "Development", "Production".

# This is to 'use' the module(s), so lint doesn't complain

assert Entity
assert Config
assert LicenseInfo
assert LicenseFeatures
assert VALID_CREDENTIAL_TYPES
assert JOB_TYPES
assert VERBOSITY_LEVELS
assert Organization
assert User
assert Team
assert Project
assert Group
assert Inventory
assert Host
assert Instance
assert InstanceGroup
assert CredentialType
github schubergphilis / towerlib / towerlib / entities / instance.py View on Github external
__docformat__ = '''google'''
__date__ = '''2018-01-03'''
__copyright__ = '''Copyright 2018, Costas Tyfoxylos'''
__credits__ = ["Costas Tyfoxylos"]
__license__ = '''MIT'''
__maintainer__ = '''Costas Tyfoxylos'''
__email__ = ''''''
__status__ = '''Development'''  # "Prototype", "Development", "Production".

# This is the main prefix used for logging
LOGGER_BASENAME = '''instances'''
LOGGER = logging.getLogger(LOGGER_BASENAME)
LOGGER.addHandler(logging.NullHandler())


class Instance(Entity):
    """Models the instance entity of ansible tower."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def uuid(self):
        """The uuid of the instance.

        Returns:
            string: The uuid of the instance.

        """
        return self._data.get('uuid')

    @property
github schubergphilis / towerlib / towerlib / entities / schedule.py View on Github external
"""
Main code for Schedule.

.. _Google Python Style Guide:
   http://google.github.io/styleguide/pyguide.html

"""

from towerlib.towerlibexceptions import (InvalidJobType,
                                         InvalidVerbosity)
from .core import Entity, JOB_TYPES, VERBOSITY_LEVELS
from .inventory import Inventory


class Schedule(Entity):
    """Models the schedule entity of ansible tower."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def recurrence_rule(self):
        """A value representing the schedules iCal recurrence rule.

        Returns:
            string: A value representing the schedules iCal recurrence rule.

        """
        return self._data.get('rrule')

    @property
github schubergphilis / towerlib / towerlib / entities / notification.py View on Github external
    @property
    def recent_notifications(self):
        """The groups configured in Tower/AWX.

        Returns:
            EntityManager: The manager object for groups

        """
        url = self._data.get('related', {}).get('notifications')
        return EntityManager(self._tower,
                             entity_object='Notification',
                             primary_match_field='subject',
                             url=url)


class Notification(Entity):
    """Models the notifications of Ansible Tower/AWX."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def error(self):
        """The error status for the notification.

        Returns:
            string: The error

        """
        return self._data.get('error')

    @property
github schubergphilis / towerlib / towerlib / entities / host.py View on Github external
__docformat__ = '''google'''
__date__ = '''2018-01-03'''
__copyright__ = '''Copyright 2018, Costas Tyfoxylos'''
__credits__ = ["Costas Tyfoxylos"]
__license__ = '''MIT'''
__maintainer__ = '''Costas Tyfoxylos'''
__email__ = ''''''
__status__ = '''Development'''  # "Prototype", "Development", "Production".

# This is the main prefix used for logging
LOGGER_BASENAME = '''host'''
LOGGER = logging.getLogger(LOGGER_BASENAME)
LOGGER.addHandler(logging.NullHandler())


class Host(Entity):
    """Models the host entity of ansible tower."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def name(self):
        """The name of the host.

        Returns:
            string: The name of the host.

        """
        return self._data.get('name')

    @name.setter
github schubergphilis / towerlib / towerlib / entities / job.py View on Github external
"""
        return self._data.get('skipped')

    @property
    def failed(self):
        """Whether the job is failed or not.

        Returns:
            bool: Whether the job is failed or not.

        """
        return self._data.get('failed')


class JobRun(Entity):  # pylint: disable=too-many-public-methods
    """Models the Job entity of ansible tower."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def created_by(self):
        """The User that created the job.

        Returns:
            User: The user that created the job in tower.

        """
        url = self._data.get('related', {}).get('created_by')
        return self._tower._get_object_by_url('User', url)  # pylint: disable=protected-access
github schubergphilis / towerlib / towerlib / entities / job.py View on Github external
"""
        return self._data.get('end_line')

    @property
    def verbosity(self):
        """The verbosity of the event.

        Returns:
            integer: The verbosity of the event.

        """
        return self._data.get('verbosity')


class JobSummary(Entity):
    """Models the Job entity of ansible tower."""

    def __init__(self, tower_instance, data):
        Entity.__init__(self, tower_instance, data)

    @property
    def summary_fields(self):
        """The summary_fields of this job summary.

        Returns:
            dict: The summary_fields of this job summary.

        """
        return self._data.get('summary_fields')

    @property