예제 #1
0
    def xr_addhost(self, macaddress, hostname, ipaddress, oid=None):

        xrd = XRoad()
        xrd.addhost(macaddress, hostname, ipaddress, oid)
        if oid is not None:
            xrd.markhost(str(oid), ipaddress)

        return True
예제 #2
0
    def xr_remhost(self, ipaddress, oid):

        try:
            xrd = XRoad()
            xrd.remhost(ipaddress)
            if oid is not None:
                xrd.unmarkhost(str(oid), ipaddress)
        except Exception:
            pass

        return True
예제 #3
0
class XRoadTool:
    def __init__(self):
        self.x = XRoad()

    def addhost(self, macaddress, hostname=None):
        self.x.addhost(macaddress, hostname)
        print "Added host " + macaddress + " to XRoad Monitoring"
        return True

    def remhost(self, macaddress):
        self.x.remhost(macaddress)
        print "Removed host " + macaddress + " from XRoad Monitoring"

    def initialize(self):
        print "Initializing XRoad ... ",
        self.x.initdb()
        print "done"

    def listhosts(self):
        hosts = self.x.listhosts()
        if len(hosts) > 0:
            print "Hostname\t\tMAC Address"
            for h in hosts:
                print h[1] + "\t\t" + h[2]
        else:
            print "No hosts being monitored"
예제 #4
0
class JunxonUtil:

    def __init__(self, ipaddress, macaddress):
        self.j = Junxon()
        self.x = XRoad()
        self.ipaddress = ipaddress
        self.macaddress = macaddress

    def disconnect(self):
        self.j.disable_subscription(self.ipaddress, self.macaddress)
        self.j.remove_dhcp_record_by_mac(self.macaddress)
        
        sub = Subscriber.objects.filter(macaddress=self.macaddress, ipaddress=self.ipaddress, active=True)
        for s in sub:
            self.x.remhost(self.ipaddress, s.id) # Stop host from being monitored
            s.active=False
            s.save()
        return True
예제 #5
0
class XRoadD:
    
    def __init__(self):
        self.x = XRoad()

    def flush_current(self):
        self.x.flushall()

    def mark_hosts(self):
        self.x.markall()
        
    def updator(self):
        self.x.updreading()

    def gengraphs(self):
        self.x.gengraphs()
예제 #6
0
 def __init__(self, ipaddress, macaddress):
     self.j = Junxon()
     self.x = XRoad()
     self.ipaddress = ipaddress
     self.macaddress = macaddress
예제 #7
0
 def __init__(self):
     self.x = XRoad()
예제 #8
0
 def xr_flushall(self):
     xrd = XRoad()
     xrd.flushall()
     return True