Esempio n. 1
0
    def __init__(self, id, location=None, collectorName=None, timeout=None):
        Node.__init__(self, collectorName=collectorName, timeout=timeout)
        self.__id = id
        self.__configNames = set()

        if location is not None:
            Edge(self, location)
Esempio n. 2
0
    def __init__(self, id, collectorName=None, timeout=None):
        Node.__init__(self, collectorName=collectorName, timeout=timeout)

        self.__id = id.lower()
        self.__type = None
        self.__defaultTemplate = None

        #get the type of the Location
        if os.path.isfile(LOCATIONS_CONF):
            locationConf = ConfigObj(LOCATIONS_CONF)
            if self.__id in locationConf:
                loc = locationConf[self.__id]
                if 'hypervisor' in loc:
                    self.__type = loc['hypervisor']
                #read all templates
                if 'templates' in loc:
                    for k in loc['templates'].keys():
                        metadata = ""
                        if 'metadata' in loc['templates'][k]:
                            metadata = loc['templates'][k]['metadata']
                        self.addTemplate(Template(k, metadata))
                #get the default template
                if "default_template" in loc:
                    self.__defaultTemplate = [
                        t for t in self.getTemplates()
                        if t.getID() == loc['default_template']
                    ]
                    if len(self.__defaultTemplate) > 0:
                        self.__defaultTemplate = self.__defaultTemplate[0]
Esempio n. 3
0
    def __init__(self, firewall, data=None, collectorName=None, timeout=None):
        Node.__init__(self, collectorName=collectorName, timeout=timeout)
        self.firewall = firewall

        #remove left whitespaces on each line
        ls = [l.lstrip(' ') for l in data.splitlines()]
        self.data = "\n".join(ls[1:])
Esempio n. 4
0
 def __init__(self,
              address,
              netmask=None,
              gateway=None,
              collectorName=None,
              timeout=None):
     Node.__init__(self, collectorName=collectorName, timeout=timeout)
     self.address = address
     self.netmask = netmask
     self.gateway = gateway
     self.static = False
Esempio n. 5
0
    def __init__(self,
                 dest,
                 gen,
                 gateway,
                 interface=None,
                 collectorName=None,
                 timeout=None):
        Node.__init__(self, collectorName=collectorName, timeout=timeout)
        self.destination = dest
        self.genmask = gen
        self.gateway = gateway

        if interface:
            self.setInterface(interface, collectorName, timeout)
Esempio n. 6
0
    def __init__(self, chain, action, protocol, srcnet=None, destnet=None, srcports=None, destports=None, inInterface=None, outInterface=None, collectorName=None, timeout=None):
        Node.__init__(self, collectorName=collectorName, timeout=timeout)
        self.chain = chain
        self.action = action
        self.protocol = protocol
        self.srcnet = srcnet
        self.destnet = destnet
        self.srcports = srcports
        self.destports = destports

        if outInterface:
            Edge(self, outInterface, collectorName, timeout, association="outInterface", changed=self, name="outInterface")

        if inInterface:
            Edge(self, inInterface, collectorName, timeout, association="inInterface", changed=self, name="inInterface")
Esempio n. 7
0
 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)
Esempio n. 8
0
    def __init__(self, mac, network=None, collectorName=None, timeout=None):
        """
        Method creating new interface opject.

        :param mac: MAC-address of this interface. (Used as identifier)
        :type mac: str

        :param network: 'Network' object this interface is connected to
        :type network: insalata.model.Layer2Network
        """
        Node.__init__(self, collectorName=collectorName, timeout=timeout)
        self.__mac = mac
        self.networkId = None
        self.rate = None  # In kbps
        self.mtu = None

        if network:
            Edge(self, network, collectorName=collectorName, timeout=timeout)
            self.networkId = network.getID()
Esempio n. 9
0
    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)
Esempio n. 10
0
    def __init__(self,
                 id,
                 allL2Networks=set(),
                 allL3Networks=set(),
                 locations=set(),
                 allHosts=set()):
        Node.__init__(self)
        self.id = id
        for host in allHosts:
            Edge(self, host)

        for network in allL2Networks:
            Edge(self, network)

        for network in allL3Networks:
            Edge(self, network)

        for location in locations:
            Edge(self, location)

        self.__locks = {
            Host: threading.Lock(),
            DhcpService: threading.Lock(),
            Disk: threading.Lock(),
            DnsService: threading.Lock(),
            Interface: threading.Lock(),
            Layer2Network: threading.Lock(),
            Layer3Address: threading.Lock(),
            Layer3Network: threading.Lock(),
            Location: threading.Lock(),
            Route: threading.Lock(),
            Service: threading.Lock(),
            FirewallRule: threading.Lock(),
            FirewallRaw: threading.Lock()
        }

        self.__objectChangedEvent = Event()
        self.__objectNewEvent = Event()
        self.__objectDeletedEvent = Event()

        self.__out = open("output.txt", "w")
Esempio n. 11
0
 def __init__(self, name, size=None, collectorName=None, timeout=None):
     Node.__init__(self, collectorName=collectorName, timeout=timeout)
     self.__id = name
     self.__size = size
Esempio n. 12
0
    def __init__(self, id, metadata):
        Node.__init__(self)

        self.id = id
        self.metadata = metadata
Esempio n. 13
0
 def __init__(self, id, address, netmask, collectorName=None, timeout=None):
     Node.__init__(self, collectorName=collectorName, timeout=timeout)
     self.__id = id
     self.netmask = netmask
     self.address = address