예제 #1
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"
예제 #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 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