def addService(self, service, collectorName=None, timeout=None): """ Add a service to this layer 3 address. :param service: Service to add to this address :type service: insalata.model.Layer3Address.Layer3Address :param collectorName: Name of the collector module adding this value :type collectorName: str :param timeout: Timeout the collecor module uses :type timeout: int """ if not service: return if service not in self.getAllNeighbors(Service): PartOfEdge(service, self, collectorName=collectorName, timeout=timeout, association="service", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == service ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def addAddress(self, address, collectorName=None, timeout=None): """ Add a Layer3Address object to this interface. :param address: The layer 3 address object which shall be connected to the interface :param type: insalata.model.Layer3Address.Layer3Address :param collectorName: Name of the collector module setting the address :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ if address not in self.getAllNeighbors(Layer3Address): PartOfEdge(address, self, collectorName=collectorName, timeout=timeout, association="address", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == address ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def addDisk(self, disk, collectorName=None, timeout=None): """ Add a disk to this host. :param disk: Rule to add :type disk: insalata.model.Disk.Disk :param collectorName: Name of the collector module setting the disk :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ if disk not in self.getAllNeighbors(Disk): PartOfEdge(disk, self, collectorName=collectorName, timeout=timeout, association="disk", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == disk ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def setTemplate(self, newTemplate, collectorName=None, timeout=None): """ Set the template this host is build on. :param newTemplate: New template a collector found :type newTemplate: insalata.model.Template.Template :param collectorName: Name of the collector module setting the template :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ if newTemplate and (len(self.getAllNeighbors(type=Template)) == 0 or newTemplate != self.getTemplate()): for edge in self.getEdges(): if isinstance(edge.getOther(self), Template): edge.delete() PartOfEdge(newTemplate, self, collectorName=collectorName, timeout=timeout, association="template", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == newTemplate ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def setFirewallRaw(self, raw, collectorName=None, timeout=None): """ Set the raw firewall dump for this host. :param raw: Raw firewall data to set :type raw: insalata.model.FirewallRaw.FirewallRaw :param collectorName: Name of the collector module setting the raw data :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ if raw not in self.getAllNeighbors(FirewallRaw): for edge in [ e for e in self.getEdges() if isinstance(e, FirewallRaw) ]: edge.delete(association="firewallRaw", changed=self) PartOfEdge(raw, self, collectorName=collectorName, timeout=timeout, association="firewallRaw", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == raw ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def addFirewallRule(self, newRule, collectorName=None, timeout=None): """ Add a firewall rule to this host. :param newRule: Rule to add :type newRule: insalata.model.FirewallRule.FirewallRule :param collectorName: Name of the collector module setting the firewall rule :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ if newRule not in self.getAllNeighbors(FirewallRule): PartOfEdge(newRule, self, collectorName=collectorName, timeout=timeout, association="firewallRule", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == newRule ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def addInterface(self, newInterface, collectorName=None, timeout=None): """ Add an interface to this host. :param newInterface: Interface to add :type newInterface: insalata.model.Interface.Interface :param collectorName: Name of the collector module setting the interface :type collectorName: str :param timeout: Timeout the collector uses :type timeout: int """ edges = [ e for e in self.getEdges() if e.getOther(self) == newInterface ] if len(edges) == 0: PartOfEdge(newInterface, self, collectorName=collectorName, timeout=timeout, association="interface", changed=self) else: for edge in edges: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)
def addTemplate(self, template): """ Add a template to this location. :param template: Template to add :type template: insalata.model.Template.Template """ edges = [e for e in self.getEdges() if e.getOther(self) == template] if len(edges) == 0: PartOfEdge(template, self)
def __init__(self, port, protocol, type, collectorName=None, timeout=None, address=None): Node.__init__(self, collectorName=collectorName, timeout=timeout) self.port = port self.type = type self.protocol = protocol self.product = None self.version = None if address: PartOfEdge(self, address, collectorName=collectorName, timeout=timeout)
def __init__(self, id, location=None, template=None, collectorName=None, timeout=None): """ Create a new host object. Keyword arguments: id -- Name of this host. location -- Location of this host. In Xen environment: Xen Server. template -- Template used to clone this host. collectorName -- Scanner that verifies the new host. timeout -- Timeout to delete the new host without new verify """ Node.__init__(self, collectorName=collectorName, timeout=timeout) self.__id = id self.cpus = None self.cpuSpeed = None self.memoryMax = None self.memoryMin = None self.powerState = None self.__configNames = set() self.__nameApplied = not (self.__id == template) if location: Edge(self, location, collectorName=collectorName, timeout=timeout, association="location", changed=self) if template: PartOfEdge(template, self, collectorName=collectorName, timeout=timeout, association="template", changed=self)
def setAddress(self, address, collectorName, timeout): if not address: return if address != self.getAddress(): for edge in self.getEdges(): #Delete old edges if isinstance(edge.getOther(self), Layer3Address): edge.delete(association="address", changed=self) PartOfEdge(self, address, collectorName=collectorName, timeout=timeout, association="address", changed=self) else: for edge in [ e for e in self.getEdges() if e.getOther(self) == address ]: edge.verify(collectorName, timeout) self.verify(collectorName, timeout)