def __init__(self): ShowBase.__init__(self) self.originals = {} blades = [] servers = [] self.setBackgroundColor(0.69,0.77,0.88) self.skybox = self.loader.loadModel(getPath("model", "skysphere.egg")) self.skyboxTexture = self.loader.loadTexture(getPath("image", "floor.jpg")) self.skyboxTexture.setWrapU(Texture.WMRepeat) self.skyboxTexture.setWrapV(Texture.WMRepeat) self.skybox.setTexture(self.skyboxTexture, 1) self.skybox.reparentTo(render) self.skybox.setScale(500) plight = PointLight('my plight') plight.setAttenuation(Point3(2, 0, 0)) plnp = render.attachNewNode(plight) plnp.setPos(120, -320, 30) render.setLight(plnp) self.disableMouse() self.useDrive() base.drive.node().setPos(120, -320, 30) base.drive.node().setHpr(360, 0, 0) for i in range(16): blades.append(NodePath(str(i))) blades[i].show() blades[i].reparentTo(render) blades[i].setPos(i*15, 0, 0) blades[i].setColorScale(0, .8, 0, 1) blades[i].setTag('state', 'in') #blades[i].setScale(1, 4, 4) #blades[i].setTransparency(1) #blades[i].setColorScale(.2, .2, .2, .4) for j in range(16): this_server = self.loader.loadModel(getPath("model", "low-cube.egg")) servers.append(this_server) this_server.reparentTo(blades[i]) y = (j % 4) * 10 z = (int(j/4)) * 10 this_server.setPos(0, y, z) this_server.setColorScale(0, .8, 0, 1) name = str(i) + "=" + str(j) this_server.setTag('myObjectTag', name) self.myHandler = CollisionHandlerQueue() self.myTraverser = CollisionTraverser() #base.cTrav = self.myTraverser pickerNode = CollisionNode('mouseRay') pickerNP = camera.attachNewNode(pickerNode) pickerNode.setFromCollideMask(GeomNode.getDefaultCollideMask()) self.pickerRay = CollisionRay() pickerNode.addSolid(self.pickerRay) self.myTraverser.addCollider(pickerNP, self.myHandler)
def place_server(self, panda, counter, IP, servers): xcoord = 0 ycoord = 0 zcoord = 0 for i in self.master_zone_array: for j in i: subnet_number = i.index(j) zone_number = self.master_zone_array.index(i) if self.is_member_subnet(IP, j.split()): z = subnet_number-2 y = zone_number self.x[j] = self.x[j]+1 xcoord = self.x[j] ycoord = y zcoord = z offset = 8 * zone_number #red = 0.1 + 2*((float(zone_number)+1)/10) num = 2 * (zone_number + 1) red = float(float(num) % 10)/10.0 #tran = 6.0 - (float(y) / 20.0) tran = 0.7 basecolor = (red, 0.41, 0.60, tran) coords = xcoord*10, ycoord*(-24), zcoord*12 servers[IP] = panda.loader.loadModel(getPath("model", "crt.egg")) servers[IP].reparentTo(panda.hybridview) servers[IP].setScale(4, 4, 4) servers[IP].setPos(xcoord*10, ycoord*(-24), zcoord*12+offset) servers[IP].setTransparency(True) servers[IP].setColorScale(basecolor) servers[IP].setTag("myObjectTag", IP) if parse_nmap.networkMap[IP].osclass == "Mac OS X": finalcolor = (basecolor[0], basecolor[1]+0.2, basecolor[2]+0.2, basecolor[3]) elif parse_nmap.networkMap[IP].osclass == "Linux": finalcolor = (basecolor[0], basecolor[1]-0.1, basecolor[2]+0.1, basecolor[3]) elif parse_nmap.networkMap[IP].osclass == "Windows": finalcolor = (basecolor[0], basecolor[1]-0.2, basecolor[2]-0.2, basecolor[3]) elif parse_nmap.networkMap[IP].osclass == "Solaris": finalcolor = (basecolor[0], basecolor[1]+0.1, basecolor[2]-0.1, basecolor[3]) else: finalcolor = basecolor servers[IP].setColorScale(finalcolor) text = TextNode(IP) try: hostname = socket.gethostbyaddr(IP)[0] except socket.herror: hostname = "Unknown" os = parse_nmap.networkMap[IP].osclass text.setText(hostname[:8] + "\n" + IP + "\n" + os) self.names[IP] = panda.hybridview.attachNewNode(text) self.names[IP].reparentTo(servers[IP]) self.names[IP].setPos( -1.8, -1.5, 1.5) self.names[IP].setScale(.25, .25, .25) distance = self.threedee_math.distance_between(base.drive.node().getPos(), coords)
def __init__(self, panda, ip_array): self.panda = panda self.nodes = {} self.slugs = {} self.positions = [] self.intervals = [] self.slug = self.panda.loader.loadModel(getPath("model", "slug2.egg")) self.slug.reparentTo(render) self.slug.setTransparency(1) self.slug.setColorScale(0.8, 0.2, 0.2, 1) self.slug.setScale(4, 3, 3) for ip in ip_array: self.nodes[ip] = self.panda.loader.loadModel(getPath("model","crt.egg")) self.nodes[ip].reparentTo(render) x = ip_array.index(ip)*-30 y = 0 z = 0 self.nodes[ip].setPos(x, y, z) self.nodes[ip].setTransparency(1) self.nodes[ip].setColorScale (0.5, 0.5, 0.8, 1) if ip_array.index(ip) == 0: starting_position = (x+30, y, z) self.positions.append((x, y, z)) else: idx = ip_array.index(ip) - 1 print idx starting_position = self.positions[idx] self.positions.append((x, y, z)) print ip print str(starting_position) + " to " + str(self.nodes[ip].getPos()) self.intervals.append (self.slug.posInterval(10, self.nodes[ip].getPos(), startPos = Point3(starting_position))) #pos1 = self.slugs[ip].posInterval(10, Point3(0, 0, 0), startPos=Point3(30, 0, 0)) #pos2 = self.slugs[ip].posInterval(10, Point3(-30, 0, 0), startPos=Point3(0, 0, 0)) #pos3 = self.slugs[ip].posInterval(10, Point3(-60, 0, 0), startPos=Point3(-30, 0, 0)) self.pingpong = Sequence(name="pingpong") for i in self.intervals: self.pingpong.append(i) self.pingpong.loop()
def __init__(self, IP, panda): self.threedee_math = threedee_math.threedee_math() self.panda = panda self.IP = IP self.x = {} self.panda.model.servers[IP] = True for i in self.panda.model.master_zone_array: for j in i: self.x[j] = 0 self.panda.model.servers[IP] = self.panda.loader.loadModel(getPath("model", "crt.egg")) self.rearrangeServers()
def __init__(self, panda): self.blades = [] self.servers = [] number_of_blades = len(panda.model.servers) % 16 for blade_num in range(number_of_blades): self.blades.append(panda.NodePath(blade_num)) self.blades[blade_num].show() self.blades[blade_num].reparentTo(render) self.blades[blade_num].setPos(blade_num*15, 0, 0) self.blades[blade_num].setTag('state', 'in') for server in panda.model.servers: num = panda.model.servers.index(server) blade_num = int((num / 16) +1) self.servers.append(panda.loader.loadModel(getPath("model", "crt.egg"))) self.servers[num].reparentTo(self.blades[blade_num]) y = ((num % 16) % 4) * 10 z = (int((num % 16)/4)) * 10 self.servers[num].setPos(0, y, z)
import sys import xml.sax from xml.sax.handler import feature_namespaces, ContentHandler import gibson import traceback # Main if __name__ == '__main__': from gibson.programs import network from gibson import parse_nmap option_parser = OptionParser() option_parser.add_option("-x", "--xml", dest="xmlfile", help="XMLFILE to use as input", metavar="XMLFILE") option_parser.add_option("-c", "--config", dest="configfile", help="read configuration from FILE", metavar="FILE") (options, args) = option_parser.parse_args() #threedee_math = threedee_math.threedee_math() parser = xml.sax.make_parser() parser.setFeature(feature_namespaces, 0) dh = parse_nmap.ImportServer() parser.setContentHandler(dh) try: print gibson.getPath("xml", options.xmlfile) parser.parse(gibson.getPath("xml", options.xmlfile)) except: traceback.print_exc() print "You have not specified an xml model. I'll assume you know what you're doing...." scene = network.Panda(options) network.scene = scene scene.run()
def __init__(self): ShowBase.__init__(self) self.slugs = {} self.lasts = {} self.view = "hybrid" self.hybridview = NodePath("hybridview") self.hybridview.reparentTo(render) self.subnetview = NodePath("subnetview") self.subnetview.reparentTo(render) self.subnetview.hide() self.dummy_center_node = render.attachNewNode("dummy_center_node") self.dummy_center_node.setPos(0, 0, 0) self.setBackgroundColor(0.69,0.77,0.88) self.skybox = self.loader.loadModel(getPath("model","skysphere.egg")) self.skyboxTexture = self.loader.loadTexture(getPath("image","tron.png")) self.skyboxTexture.setWrapU(Texture.WMRepeat) self.skyboxTexture.setWrapV(Texture.WMRepeat) self.skybox.setTexture(self.skyboxTexture, 1) self.skybox.reparentTo(self.hybridview) self.skybox.setScale(500) self.skybox.setH(60) self.disableMouse() self.useDrive() base.drive.node().setPos(0, -30, 0) base.drive.node().setHpr(0, 0, 0) plight = PointLight('my plight') plnp = self.hybridview.attachNewNode(plight) plnp.reparentTo(render) plnp.setPos(0, -5, 5) #plnp.setHpr(310, 0 ,30) #self.hybridview.setLight(plnp) render.setLight(plnp) alight = AmbientLight('alight') alight.setColor(VBase4(0.4, 0.4, 0.4, 1)) alnp = self.hybridview.attachNewNode(alight) self.hybridview.setLight(alnp) keys = keyboard_events.KeyboardEvents(base.drive.node(), self) self.model = build_cluster.BuildModel(self, sys.argv[1]) self.taskMgr.add(self.followCameraTask, "FollowCameraTask") # Get Mouse Clicks self.myHandler = CollisionHandlerQueue() self.myTraverser = CollisionTraverser() pickerNode = CollisionNode('mouseRay') pickerNP = camera.attachNewNode(pickerNode) pickerNode.setFromCollideMask(GeomNode.getDefaultCollideMask()) self.pickerRay = CollisionRay() pickerNode.addSolid(self.pickerRay) self.myTraverser.addCollider(pickerNP, self.myHandler) # Receive events self.cManager = QueuedConnectionManager() self.cReader = QueuedConnectionReader(self.cManager, 0) self.cWriter = ConnectionWriter(self.cManager,0) activeConnections=[] udpSocket = self.cManager.openUDPConnection(1723) self.cReader.addConnection(udpSocket) self.taskMgr.add(self.tskReaderPolling,"Poll the connection reader",-40) # Create GUI and switch modes / views interface = gui.KeyboardEvents(keys, self.model, base.drive.node(), self)
def __init__(self, panda, IP, services): self.IP = IP self.panda = panda self.services = services self.apps = {} self.app_info = {} self.app_names = {} if self.panda.options.configfile: conf_file = self.panda. options.configfile else: conf_file = 'None' configuration = config.ConfigFile(conf_file) if configuration.skyshape(): skybox_model = getPath("model", configuration.skyshape()) else: skybox_model = getPath("model", "skybox.egg") print skybox_model try: self.skybox = self.panda.loader.loadModel(skybox_model) except: print "Skybox Model not found" raise if configuration.skybox_texture(): texture =getPath( "image", configuration.skybox_texture()) else: texture=getPath("image", "sky.jpg") print texture try: self.skyboxTexture = self.panda.loader.loadTexture(texture) except: print "Skybox texture not found." raise #self.skybox = self.panda.loader.loadModel("models/skybox.egg") #texture = "images/" + configuration.skybox_texture() #self.skyboxTexture = self.panda.loader.loadTexture(texture) self.skybox.setTexture(self.skyboxTexture, 1) self.skybox.reparentTo(self.panda.nodeview) self.skybox.setScale(1) self.skybox.setH(60) plight = PointLight('my plight') plight.setAttenuation(Point3(1, 0, 0)) plnp = self.panda.nodeview.attachNewNode(plight) plnp.reparentTo(self.panda.camera) self.panda.nodeview.setLight(plnp) self.panda.dummy_center_node.setH(0) self.panda.dummy_center_node.setPos(0, 0, 0) self.panda.camera.setPos(-10, -180, 200) self.panda.camera.setHpr(90, 0, 0) self.main_node = self.panda.loader.loadModel(getPath("model","crt.egg")) self.main_node.reparentTo(panda.nodeview) self.main_node.setScale(16, 16, len(services) * 8.5) self.main_node.setTransparency(1) self.main_node.setColorScale(0.4, 0.2, 0.7, 0.4) self.main_node.setPos(30, 0, 0) for service in services: self.apps[service] = self.panda.loader.loadModel(getPath("model", "drawer.egg")) self.apps[service].reparentTo(self.main_node) self.apps[service].setScale(.3, .3, .3) z = ((services.index(service)+0.5) / 2.2) self.apps[service].setPos(-0.5, 0, z) self.apps[service].setTransparency(0) self.apps[service].clearColor() self.apps[service].setColorScale(1, 0.4, 0.7, 1.0) self.app_info[service] = TextNode(str(service)) portnum = int(service[0]) protocol = service[1].encode('ascii', 'ignore') print str(portnum) + " " + protocol try: srvname = socket.getservbyport(portnum, protocol) except: srvname = "unknown" self.app_info[service].setText(srvname + "\n" + str(portnum) + "/" + protocol) self.app_names[service] = self.apps[service].attachNewNode(self.app_info[service]) self.app_names[service].setPos(-3, -5, 0) self.app_names[service].setScale(0.25, 0.25, 0.25) self.app_names[service].setColor(0, 0, 0, 1) text = TextNode(IP) try: hostname = socket.gethostbyaddr(IP)[0] except socket.herror: hostname = "Unknown" text.setText(hostname[:8] + "\n" + IP + "\n") self.name = self.main_node.attachNewNode(text) #self.names[IP].reparentTo(servers[IP]) self.name.setPos( 0, 3, 5.5) self.name.setScale(0.5, 0.5, 0.5) self.name.setColor(0, 0, 0, 1) self.name.setTransparency(0) text2 = TextNode('2') text2.setText(text.getText()) self.name2 = self.main_node.attachNewNode(text2) self.name2.setPos( 0, 3, -5) self.name2.setScale(0.5, 0.5, 0.5) self.name2.setColor(0, 0, 0) self.name2.setTransparency(0) self.looper = Parallel(name="looper")