def server_poll(self, device=Device): """ takes a query object of type Device, connects to that host, and then gets all the vip info then all the information is entered into the database :param device: query object :return: """ remote = Netscaler(host=device.ip, username=device.login.user, password=device.login.password) for key, val in remote.get_servers().iteritems(): Server.objects.update_or_create( name=val["Name"], address=val["IPAddress"], state=val["State"], device=device )
def vips_poll(self, device=Device, debug=False): """ connects to the netscaler gets all the vip data and enters it into the db :return: """ remote = Netscaler(host=device.ip, username=device.login.user, password=device.login.password) for key, val in remote.get_vips(debug=debug).iteritems(): Vip.objects.update_or_create( label=val["label"], address=val["address"], port=val["port"], state=val["state"], effective_state=val["effective state"], device=device, )
def members_poll(self, vip=Vip, debug=False): """ :param device: :return: """ remote = Netscaler(host=vip.device.ip, username=vip.device.login.user, password=vip.device.login.password) for key, val in remote.get_members(vip.label).iteritems(): if debug == True: print key, val if val != "empty": Member.objects.update_or_create( label=val["label"], address=val["address"], port=val["port"], protocol=val["protocol"], state=val["state"], vip=vip, )