# Path: opennode/knot/model/compute.py
# class ICompute(Interface):
#     # Network parameters
#     hostname = RestrictedHostname(title=u"Host name", min_length=1)
#     mac_address = schema.TextLine(title=u'MAC address', min_length=17, max_length=23, required=False,
#                                   description=u'MAC address, formatted as a set of colon-separated '
#                                   'hexadecimal octet values')
#     ipv4_address = schema.TextLine(title=u"IPv4 address", min_length=7, required=False)
#     ipv6_address = schema.TextLine(title=u"IPv6 address", min_length=6, required=False)
#     nameservers = schema.List(title=u"Nameservers", description=u"IPs of DNS servers",
#                               value_type=schema.TextLine(), required=False)
#     dns_domains = schema.List(
#         title=u"DNS Domains", description=u"Domain names used for DNS host name lookup",
#         value_type=schema.TextLine(), required=False)
# 
#     # Hardware/platform info
#     architecture = schema.Tuple(
#         title=u"Architecture", description=u"OS arch, OS type, OS distribution/flavour",
#         value_type=schema.TextLine(), max_length=3, min_length=3,
#         required=False, readonly=True)
#     cpu_info = schema.TextLine(
#         title=u"CPU Info", description=u"Info about the CPU such as model, speed in Hz, cache size",
#         required=False, readonly=True)
#     os_release = schema.TextLine(
#         title=u"OS Release", description=u"OS version info",
#         required=False, readonly=True)
#     kernel = schema.TextLine(
#         title=u"Kernel", description=u"Kernel version (if applicable)",
#         required=False, readonly=True)
# 
#     # State
#     state = schema.Choice(
#         title=u"State", values=(u'starting', u'active', u'stopping', u'inactive', u'suspended'),
#         required=False, default=u'inactive')
#     effective_state = schema.TextLine(
#         title=u"Effective state", readonly=True, required=False)
# 
#     autostart = schema.Bool(title=u"Autostart", description=u"Start on boot", required=False)
# 
#     # Processing/network capabilities:
#     num_cores = schema.Int(
#         title=u"Num. Cores", description=u"Total number of cores across all CPUs",
#         required=False)
#     memory = schema.Int(
#         title=u"RAM Size in MB", description=u"RAM size in MB",
#         required=False)
#     diskspace = schema.Dict(
#         title=u"Disk size in MB", description=u"List of disk partition sizes",
#         key_type=schema.TextLine(), value_type=schema.Float(),
#         required=False, readonly=True)
#     network = schema.Float(
#         title=u"Network", description=u"Network bandwidth in Bps",
#         required=False, readonly=True)
#     swap_size = schema.Int(
#         title=u"Swap Size in MB", description=u"Swap size",
#         required=False)
# 
#     # Resource utilization/load:
#     uptime = schema.Float(
#         title=u"Uptime", description=u"Uptime in seconds",
#         required=False, readonly=True)
#     cpu_usage = schema.Tuple(
#         title=u"CPU Load", description=u"CPU load during the past 1, 5 and 15 minutes",
#         value_type=schema.Float(),
#         required=False, readonly=True)
#     memory_usage = schema.Float(
#         title=u"Memory Usage", description=u"Memory usage in MB",
#         required=False, readonly=True)
#     diskspace_usage = schema.Dict(
#         title=u"Diskspace Utilization", description=u"List of disk partition usages",
#         key_type=schema.TextLine(), value_type=schema.Float(),
#         required=False, readonly=True)
#     network_usage = schema.Tuple(
#         title=u"Network Load", description=u"Network load in B/s (incoming and outgoing)",
#         value_type=schema.Float(),
#         required=False, readonly=True)
# 
#     # availability
#     last_ping = schema.Bool(title=u'Success of the last ping', required=False,
#                             readonly=True, default=False)
# 
#     pingcheck = schema.List(title=u'Ping history', required=False,
#                             readonly=True, default=[],
#                             value_type=schema.Dict(title=u'Ping result',
#                                                    required=False,
#                                                    readonly=True))
# 
#     suspicious = schema.Bool(title=u'Suspicion of unavailability',
#                              required=False, readonly=True, default=False)
# 
#     failure = schema.Bool(title=u'Availability failure', required=False,
#                           readonly=True, default=False)
# 
#     agent_version = schema.TextLine(title=u'Agent version', required=False,
#                                     readonly=True, default=u'')
# 
#     exclude_from_allocation = schema.Bool(title=u'Exclude from allocation', required=False, default=False)


from twisted.python import log
from grokcore.component import subscribe
from opennode.oms.model.model.events import IModelCreatedEvent, IModelDeletedEvent
from opennode.knot.model.compute import ICompute
from opennode.knot.model.hangar import IHangar
from __future__ import absolute_import




@subscribe(ICompute, IModelCreatedEvent)
def add_compute_to_zabbix(model, event):
    if IHangar.providedBy(model.__parent__):
        return
    # FILL IT
    log.msg("TODO: add %s to zabbix" % (model,), system='zabbix')



# Path: opennode/knot/model/compute.py
# class ICompute(Interface):
#     # Network parameters
#     hostname = RestrictedHostname(title=u"Host name", min_length=1)
#     mac_address = schema.TextLine(title=u'MAC address', min_length=17, max_length=23, required=False,
#                                   description=u'MAC address, formatted as a set of colon-separated '
#                                   'hexadecimal octet values')
#     ipv4_address = schema.TextLine(title=u"IPv4 address", min_length=7, required=False)
#     ipv6_address = schema.TextLine(title=u"IPv6 address", min_length=6, required=False)
#     nameservers = schema.List(title=u"Nameservers", description=u"IPs of DNS servers",
#                               value_type=schema.TextLine(), required=False)
#     dns_domains = schema.List(
#         title=u"DNS Domains", description=u"Domain names used for DNS host name lookup",
#         value_type=schema.TextLine(), required=False)
# 
#     # Hardware/platform info
#     architecture = schema.Tuple(
#         title=u"Architecture", description=u"OS arch, OS type, OS distribution/flavour",
#         value_type=schema.TextLine(), max_length=3, min_length=3,
#         required=False, readonly=True)
#     cpu_info = schema.TextLine(
#         title=u"CPU Info", description=u"Info about the CPU such as model, speed in Hz, cache size",
#         required=False, readonly=True)
#     os_release = schema.TextLine(
#         title=u"OS Release", description=u"OS version info",
#         required=False, readonly=True)
#     kernel = schema.TextLine(
#         title=u"Kernel", description=u"Kernel version (if applicable)",
#         required=False, readonly=True)
# 
#     # State
#     state = schema.Choice(
#         title=u"State", values=(u'starting', u'active', u'stopping', u'inactive', u'suspended'),
#         required=False, default=u'inactive')
#     effective_state = schema.TextLine(
#         title=u"Effective state", readonly=True, required=False)
# 
#     autostart = schema.Bool(title=u"Autostart", description=u"Start on boot", required=False)
# 
#     # Processing/network capabilities:
#     num_cores = schema.Int(
#         title=u"Num. Cores", description=u"Total number of cores across all CPUs",
#         required=False)
#     memory = schema.Int(
#         title=u"RAM Size in MB", description=u"RAM size in MB",
#         required=False)
#     diskspace = schema.Dict(
#         title=u"Disk size in MB", description=u"List of disk partition sizes",
#         key_type=schema.TextLine(), value_type=schema.Float(),
#         required=False, readonly=True)
#     network = schema.Float(
#         title=u"Network", description=u"Network bandwidth in Bps",
#         required=False, readonly=True)
#     swap_size = schema.Int(
#         title=u"Swap Size in MB", description=u"Swap size",
#         required=False)
# 
#     # Resource utilization/load:
#     uptime = schema.Float(
#         title=u"Uptime", description=u"Uptime in seconds",
#         required=False, readonly=True)
#     cpu_usage = schema.Tuple(
#         title=u"CPU Load", description=u"CPU load during the past 1, 5 and 15 minutes",
#         value_type=schema.Float(),
#         required=False, readonly=True)
#     memory_usage = schema.Float(
#         title=u"Memory Usage", description=u"Memory usage in MB",
#         required=False, readonly=True)
#     diskspace_usage = schema.Dict(
#         title=u"Diskspace Utilization", description=u"List of disk partition usages",
#         key_type=schema.TextLine(), value_type=schema.Float(),
#         required=False, readonly=True)
#     network_usage = schema.Tuple(
#         title=u"Network Load", description=u"Network load in B/s (incoming and outgoing)",
#         value_type=schema.Float(),
#         required=False, readonly=True)
# 
#     # availability
#     last_ping = schema.Bool(title=u'Success of the last ping', required=False,
#                             readonly=True, default=False)
# 
#     pingcheck = schema.List(title=u'Ping history', required=False,
#                             readonly=True, default=[],
#                             value_type=schema.Dict(title=u'Ping result',
#                                                    required=False,
#                                                    readonly=True))
# 
#     suspicious = schema.Bool(title=u'Suspicion of unavailability',
#                              required=False, readonly=True, default=False)
# 
#     failure = schema.Bool(title=u'Availability failure', required=False,
#                           readonly=True, default=False)
# 
#     agent_version = schema.TextLine(title=u'Agent version', required=False,
#                                     readonly=True, default=u'')
# 
#     exclude_from_allocation = schema.Bool(title=u'Exclude from allocation', required=False, default=False)


# Path: opennode/knot/backend/zabbix.py
from twisted.python import log
from grokcore.component import subscribe
from opennode.oms.model.model.events import IModelCreatedEvent, IModelDeletedEvent
from opennode.knot.model.compute import ICompute
from opennode.knot.model.hangar import IHangar

from __future__ import absolute_import




@subscribe(ICompute, IModelCreatedEvent)
def add_compute_to_zabbix(model, event):
    if IHangar.providedBy(model.__parent__):
        return
    # FILL IT
    log.msg("TODO: add %s to zabbix" % (model,), system='zabbix')



@subscribe(ICompute, IModelDeletedEvent)