def region(self, value): if isinstance(value, list) and not isinstance(value, APIList): self._region = APIList(DynectSession.get_session, 'region', None, value) elif isinstance(value, APIList): self._region = value self._region.uri = self.uri
def keys(self, value): if isinstance(value, list) and not isinstance(value, APIList): self._keys = APIList(DynectSession.get_session, 'keys', None, value) elif isinstance(value, APIList): self._keys = value self._keys.uri = self.uri
def __init__(self, zone, *args, **kwargs): """Create a :class:`DNSSEC` object :param zone: the zone this service will be attached to :param keys: a list of :class:`DNSSECKey`'s for the service :param contact_nickname: Name of contact to receive notifications :param notify_events: A ``list`` of events that trigger notifications. Valid values are "create" (a new version of a key was created), "expire" (a key was automatically expired), or "warning" (early warnings (2 weeks, 1 week, 1 day) of events) """ super(DNSSEC, self).__init__() self.valid_notify_events = ('create', 'expire', 'warning') self._zone = zone self._contact_nickname = self._notify_events = None self._keys = APIList(DynectSession.get_session, 'keys') self._active = None self.uri = '/DNSSEC/{}/'.format(self._zone) if 'api' in kwargs: del kwargs['api'] self._build(kwargs) elif len(args) == 0 and len(kwargs) == 0: self._get() else: self._post(*args, **kwargs) self._keys.uri = self.uri
def _build(self, data): """Iterate over API data responses and update this object according to the data returned """ for key, val in data.items(): if key == 'keys': self._keys = APIList(DynectSession.get_session, 'keys') for key_data in val: key_data['key_type'] = key_data['type'] del key_data['type'] self._keys.append(DNSSECKey(**key_data)) elif key == 'active': self._active = Active(val) else: setattr(self, '_' + key, val) self.uri = '/DNSSEC/{}/'.format(self._zone) self._keys.uri = self.uri
def _build(self, data): """Build the neccesary substructures under this :class:`RTTM`""" for key, val in data.items(): if key == 'region': self._region = APIList(DynectSession.get_session, 'region') for region in val: code = region.pop('region_code', None) pool = region.pop('pool', None) status = region.pop('status', None) r = RTTMRegion(self._zone, self._fqdn, code, pool, **region) r._status = status self._region.append(r) elif key == 'monitor': if self._monitor is not None: self._monitor.zone = self._zone self._monitor.fqdn = self._fqdn else: proto = val.pop('protocol', None) inter = val.pop('interval', None) self._monitor = Monitor(proto, inter, **val) elif key == 'performance_monitor': if self._performance_monitor is not None: self._performance_monitor.zone = self._zone self._performance_monitor.fqdn = self._fqdn else: proto = val.pop('protocol', None) inter = val.pop('interval', None) self._performance_monitor = PerformanceMonitor(proto, inter, **val) elif key == 'notify_events': self._notify_events = [item.strip() for item in val.split(',')] elif key == 'active': self._active = Active(val) elif key == "task_id" and not val: self._task_id = None elif key == "task_id": self._task_id = Task(val) else: setattr(self, '_' + key, val) self._region.uri = self.uri
def __init__(self, zone, fqdn, *args, **kwargs): """Create a :class:`RTTM` object :param auto_recover: Indicates whether or not the service should automatically come out of failover when the IP addresses resume active status or if the service should remain in failover until manually reset. Must be one of 'Y' or 'N' :param ttl: Time To Live in seconds of records in the service. Must be less than 1/2 of the Health Probe's monitoring interval. Must be one of 30, 60, 150, 300, or 450. :param notify_events: A list of the events which trigger notifications. Must be one of 'ip', 'svc', or 'nosrv' :param syslog_server: The Hostname or IP address of a server to receive syslog notifications on monitoring events :param syslog_port: The port where the remote syslog server listens for notifications :param syslog_ident: The ident to use when sending syslog notifications :param syslog_facility: The syslog facility to use when sending syslog notifications. Must be one of kern, user, mail, daemon, auth, syslog, lpr, news, uucp, cron, authpriv, ftp, ntp, security, console, local0, local1, local2, local3, local4, local5, local6, or local7 :param syslog_delivery: The syslog delivery action type. 'all' will deliver notifications no matter what the endpoint state. 'change' (default) will deliver only on change in the detected endpoint state :param region: A list of :class:`RTTMRegion`'s :param monitor: The :class:`Monitor` for this service :param performance_monitor: The performance monitor for the service :param contact_nickname: Name of contact to receive notifications :param syslog_probe_fmt: see below for format: :param syslog_status_fmt: see below for format: :param syslog_rttm_fmt: see below for format: Use the following format for syslog_xxxx_fmt paramaters. %hos hostname %tim current timestamp or monitored interval %reg region code %sta status %ser record serial %rda rdata %sit monitoring site %rti response time %msg message from monitoring %adr address of monitored node %med median value %rts response times (RTTM) :param recovery_delay: number of up status polling intervals to consider service up """ super(RTTM, self).__init__() self.valid_ttls = (30, 60, 150, 300, 450) self.valid_notify_events = ('ip', 'svc', 'nosrv') self.valid_syslog_facilities = ('kern', 'user', 'mail', 'daemon', 'auth', 'syslog', 'lpr', 'news', 'uucp', 'cron', 'authpriv', 'ftp', 'ntp', 'security', 'console', 'local0', 'local1', 'local2', 'local3', 'local4', 'local5', 'local6', 'local7') self._zone = zone self._fqdn = fqdn self.uri = '/RTTM/{}/{}/'.format(self._zone, self._fqdn) self._auto_recover = self._ttl = self._notify_events = None self._syslog_server = self._syslog_port = self._syslog_ident = None self._syslog_facility = self._monitor = None self._performance_monitor = self._contact_nickname = None self._active = self._syslog_delivery = self._syslog_probe_fmt = None self._syslog_status_fmt = self._syslog_rttm_fmt = None self._recovery_delay = None self._region = APIList(DynectSession.get_session, 'region') self._task_id = None if 'api' in kwargs: del kwargs['api'] self._build(kwargs) elif len(args) == 0 and len(kwargs) == 0: self._get() else: self._post(*args, **kwargs) self._region.uri = self.uri