def getHostName(ipAddress, defaultValue=None): """ @deprecated: Use SocketDnsResolver().resolve_hostnames(ip_address) Resolves the IP address to the host name in the DNS table. On failure to resolve the address the , default value parameter is returned. @param ipAddress: IP address to resolve @type ipAddress: string @param defaultValue: the value to return if the address cannot be resolved @return: host name of the resolved IP address @rtype: string """ if isValidIp(ipAddress): try: dnsName = str(InetAddress.getByName(ipAddress).getHostName()) if dnsName == ipAddress: return defaultValue else: return dnsName except: defultHostName = defaultValue if defultHostName == None: defultHostName = 'null' logger.debug('Could not resolve DNS name for : ', ipAddress, ',returning default value:', defultHostName, ';reason:', str(sys.exc_info()[1])) return defaultValue
def federationode(nodeName, noOfProcessors=1): from java.net import InetAddress from org.meta.net import FederationNode fNode = FederationNode(InetAddress.getByName(nodeName)) fNode.setNoOfProcessors(noOfProcessors) return fNode
def issueRequest(cls, targetHost, targetPort, forPlayerName, requestContent, timeoutClock): """ generated source for method issueRequest """ socket = Socket() theHost = InetAddress.getByName(targetHost) socket.connect(InetSocketAddress(theHost.getHostAddress(), targetPort), 5000) HttpWriter.writeAsClient(socket, theHost.getHostName(), requestContent, forPlayerName) response = HttpReader.readAsClient(socket) if (timeoutClock < 0) else HttpReader.readAsClient(socket, timeoutClock) socket.close() return response
def check_address(self, addrblobs): for addrblob in addrblobs: addr_arr = addrblob.split("|") rrow = int(addr_arr[0]) addr = addr_arr[1] try: result = InetAddress.getByName(addr) yield [rrow, "Success", result] except UnknownHostException: yield [rrow, "Fail", None]
def __init__(self, host=config.monomeHost, port=config.monomePort, prefix=config.monomePrefix, width=config.monomeWidth, height=config.monomeHeight): self.transmitter = UDPTransmitter(InetAddress.getByName(host), port) self.prefix = prefix self.width = width self.height = height
def resolveHostIpWithLocalDns(self, hostName): """ Resolves (or not) IP address by given machine name @param hostName: the machine name to resolve IPs @type hostName: string @rtype: string """ try: return InetAddress.getByName(hostName).getHostAddress() except UnknownHostException: pass
def resolveHostnamesByIp(self, ip): '''@types: str -> list[str] @raise ResolveException: Failed to resolve hostnames ''' if not ip: raise ValueError("Ip is not specified") dnsName = None try: dnsName = str(InetAddress.getByName(ip).getHostName()) except JException, je: logger.debug(str(je)) raise self._HOSTNAME_RESOLVE_EXCEPTION
def __init__(self, node, server, host): self.node = node self.server = server self.host = host ia = InetAddress.getByName(host) if (ia != None): self.host = ia.getCanonicalHostName() self.ipAddr = ia.getHostAddress() self.trustedProxy = self.ipAddr else: self.ipAddr = None self.trustedProxy = host
def _discover(self, domainDto=None): ''' if domainDto is None, domain controllers of self domain will be discovered, else controllers for specified domain will be discovered ''' result = AdDiscoveryResult() dtoToOshMap = result.getMap() siteDtoToOshMap = result.getSiteDtoToOshMap() containerOshMap = result.getContainerOshMap() client = self._daoService.getClient() serverDao = self._daoService.getServerDao() domainDao = self._daoService.getDomainDao() siteDao = self._daoService.getSiteDao() if domainDto is None: domainDto = domainDao.createDto(domainDao.obtainSelfDomainId()) serverDtos = serverDao.obtainServers(domainDto) selfControllerId = serverDao.obtainSelfServerId() for dto in serverDtos: hostOsh = None functionality = None #if this is controller that we are triggered on if selfControllerId == dto.id: dto.fullVersion = serverDao.obtainSelfFullVersion() dto.ipAddress = client.getIpAddress() if self.__isConnectionPortReported: dto.port = client.getPort() dto.username = client.getUserName() dto.credentialId = client.getCredentialId() functionality = serverDao.obtainSelfFunctionality() if self._containerOsh: hostOsh = self._containerOsh else: #determine container host try: dto.ipAddress = InetAddress.getByName( dto.dnsName).getHostAddress() hostOsh = HostBuilder.incompleteByIp(dto.ipAddress).build() except JException: logger.debug('Cannot resolve IP address for fqdn %s' % dto.dnsName) if hostOsh: siteDto = siteDao.createDto(dto.siteName) osh = self.createOsh(dto, hostOsh, functionality) dtoToOshMap[dto] = osh siteDtoToOshMap[siteDto] = osh containerOshMap[dto] = hostOsh return result
def resolveIpsByHostname(self, hostname): '''@types: str -> list[str] @raise ResolveException: Failed to resolve IPs @note: When resolved IP is local (loopback) it will be replaced with destination IP address if such was specified while initializing this DNS resolver ''' if not hostname: raise ValueError("hostname is not specified") ip = None try: ip = str(InetAddress.getByName(hostname).getHostAddress()) except JException, ex: logger.debug(str(ex)) raise self._IP_RESOLVE_EXCEPTION
def init(context): if not File("storage/python_console.props").exists(): context.log("storage/python_console.props does not exist") return context.log("storage/python_console.props exists; proceeding with load") props = Properties() props.load(FileInputStream(File("storage/python_console.props"))) server = ServerSocket(int(props["port"]), 20, InetAddress.getByName(props["host"]) if "host" in props else None) class ServerThread(Thread): def run(self): while not server.isClosed(): socket = server.accept() HandlerThread(socket).start() ServerThread().start()
def _discover(self, domainDto=None): ''' if domainDto is None, domain controllers of self domain will be discovered, else controllers for specified domain will be discovered ''' result = AdDiscoveryResult() dtoToOshMap = result.getMap() siteDtoToOshMap = result.getSiteDtoToOshMap() containerOshMap = result.getContainerOshMap() client = self._daoService.getClient() serverDao = self._daoService.getServerDao() domainDao = self._daoService.getDomainDao() siteDao = self._daoService.getSiteDao() if domainDto is None: domainDto = domainDao.createDto(domainDao.obtainSelfDomainId()) serverDtos = serverDao.obtainServers(domainDto) selfControllerId = serverDao.obtainSelfServerId() for dto in serverDtos: hostOsh = None functionality = None #if this is controller that we are triggered on if selfControllerId == dto.id: dto.fullVersion = serverDao.obtainSelfFullVersion() dto.ipAddress = client.getIpAddress() if self.__isConnectionPortReported: dto.port = client.getPort() dto.username = client.getUserName() dto.credentialId = client.getCredentialId() functionality = serverDao.obtainSelfFunctionality() if self._containerOsh: hostOsh = self._containerOsh else: #determine container host try: dto.ipAddress = InetAddress.getByName(dto.dnsName).getHostAddress() hostOsh = HostBuilder.incompleteByIp(dto.ipAddress).build() except JException: logger.debug('Cannot resolve IP address for fqdn %s' % dto.dnsName) if hostOsh: siteDto = siteDao.createDto(dto.siteName) osh = self.createOsh(dto, hostOsh, functionality) dtoToOshMap[dto] = osh siteDtoToOshMap[siteDto] = osh containerOshMap[dto] = hostOsh return result
def getHostAddress(dnsName, defaultValue=None): """ @deprecated: Use SocketDnsResolver().resolve_ips(dnsName) Resolves the host name to the IP Address in DNS table. On failure to resolve the name, the default value parameter is returned. @param dnsName: host name to resolve @type dnsName: string @param defaultValue: the value to return if the host name cannot be resolved @return: IP address of the resolved host name @rtype: string """ if dnsName and dnsName.strip(): try: return str(InetAddress.getByName(dnsName).getHostAddress()) except: logger.debugException('Could not resolve DNS name: ', dnsName) return defaultValue
def __init__(self, port=9001): self.__setPort(port) if self.debug: print 'Creating socket for receiving' # Create the socket for receiving self.sock_receive = MulticastSocket(InetSocketAddress("0", port)) self.sock_receive.joinGroup(InetAddress.getByName(MCAST_IP)) self.sock_receive.setTimeToLive(2) self.sock_receive.setSoTimeout(0) #self.sock_receive.sock_impl.jsocket = jmultisock if self.debug: print 'Socket created, bound to ', port if self.debug: print 'Joining multicast group' if self.debug: print 'Init finished' print '' thread.start_new_thread(self.receiver, ())
def __init__(self, address, port, update_interval, auto_reconnect, definitions_file_path, ftp_port, ftp_username, ftp_password): builder = NetworkDataProvider2.forAddress(InetAddress.getByName(address))\ .withInfoModelPort(port)\ .connectToRealBts()\ .reconnectAutomatically(auto_reconnect)\ .updateIntervalMs(update_interval) if definitions_file_path: object_definitions = ObjectDefinitionsFactory.getObjectDefinitions(File(definitions_file_path)) else: ftp_properties = FtpProperties(address, ftp_port, ftp_username, ftp_password) object_definitions = ObjectDefinitionsFactory.getDefinitionsFromFtp(ftp_properties) builder.objectDefinitions(object_definitions) self.provider = builder.build() self.connection_manager = ConnectionManager() self.change_manager = ModelChangeManager() self.connection_status_monitor = ConnectionStatusChangeMonitor() self.model_change_monitor = ModelChangeMonitor() self.connection_status_monitor.register(self.connection_manager) self.model_change_monitor.register(self.change_manager) self.provider.registerForConnectionStatus(self.connection_status_monitor) self.provider.registerListener(self.model_change_monitor)
# # java -cp bin:../../java-router/build/deploy/lib/RawSocket.jar:../../java-router/build/deploy/lib/JythonRouter.jar:../../java-router/ThirdParty/jython2.5.1/jython.jar Main ../../java-router/code/scripts/preconfig.py ../../java-router/code/scripts/simple-ping.py from code.messy.net.ethernet import Ethertype, ArpHandler from code.messy.net.ip import IpProtocolHandler, PacketToIp, IpPacket from code.messy.net.ip.icmp import IcmpHandler from code.messy.net.ip.route import LocalSubnet from java.net import InetAddress icmp = IcmpHandler() protocol = IpProtocolHandler() protocol.register(IpPacket.Protocol.ICMP, icmp) pak2Ip = PacketToIp(protocol) arp = ArpHandler() address = InetAddress.getByName('10.0.0.2') LocalSubnet.create(address, 24, interface['eth1']) address = InetAddress.getByName('10.1.0.2') LocalSubnet.create(address, 24, interface['eth2']) interface['eth1'].register(Ethertype.ARP, arp) interface['eth2'].register(Ethertype.ARP, arp) interface['eth1'].register(Ethertype.IP, pak2Ip) interface['eth2'].register(Ethertype.IP, pak2Ip) interface['eth1'].start() interface['eth2'].start()
def __init__(self, config): if isinstance(config, basestring): self.config = json.loads(config.decode('utf-8')) else: self.config = config self.runtime = {} #TODO: ugly ugly initialization all around, review, make it sane clusterName = "elasticsearch" host = "localhost" port = 9300 if "host" in self.config: host = self.config["host"] else: host = "localhost" if "port" in self.config: port = self.config["port"] else: port = "9300" if "bulkActions" not in self.config: self.config["bulkActions"] = 1000 if "bulkSize" not in self.config: self.config["bulkSize"] = 107374182400 if "flushInterval" not in self.config: self.config["flushInterval"] = 60000 if "concurrentRequests" not in self.config: self.config["concurrentRequests"] = 1 if "actionRetryTimeout" not in self.config: self.config["actionRetryTimeout"] = 5 if "type" not in self.config: self.config["type"] = "logs" if "indexPrefix" not in self.config: self.config["indexPrefix"] = "sampleindex" if "indexSuffix" not in self.config: self.config["indexSuffix"] = "-%Y.%m.%d" logger.debug("Initializing elasticsearch output %s: %s", self.config["indexPrefix"], json.dumps("self.config")) self.config["settings"] = Settings.builder() if "options" not in self.config: self.config["options"] = {} if "cluster" in self.config: self.config["options"]["cluster.name"] = self.config["cluster"] else: self.config["options"]["cluster.name"] = "elasticsearch" else: if "cluster.name" not in self.config["options"]: if "cluster" in self.config: self.config["options"]["cluster.name"] = self.config[ "cluster"] else: self.config["options"]["cluster.name"] = "elasticsearch" for setting in self.config["options"]: value = self.config["options"][setting] logger.info("Setting Elasticsearch options: %s = %s", setting, value) self.config["settings"].put(setting, value) self.config["settings"].build() self.runtime["client"] = PreBuiltTransportClient( self.config["settings"].build(), []) if "host" in self.config: address = InetSocketTransportAddress(InetAddress.getByName(host), int(port)) self.runtime["client"].addTransportAddress(address) if "hosts" in self.config: for hostport in self.config["hosts"]: host, port = hostport.split(":") address = InetSocketTransportAddress( InetAddress.getByName(host), int(port)) logger.info("Setting Elasticsearch host: %s = %s", host, port) self.runtime["client"].addTransportAddress(address) self.readyBulk() self.runtime["indices"] = {}
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() ms_domain_name = Framework.getDestinationAttribute('ms_domain_name') if not ms_domain_name: ms_domain_name = 'NULL' try: netUtil = MsNetworkUtil() hostsOutput = netUtil.doNetServerEnum('NULL',SV_TYPE_SERVER, ms_domain_name) if hostsOutput != None: discoverUnknownIPs = 1 try: strDiscoverUnknownIPs = Framework.getParameter('discoverUnknownIPs'); discoverUnknownIPs = Boolean.parseBoolean(strDiscoverUnknownIPs); except: pass oshMsDomain = ObjectStateHolder('msdomain') oshMsDomain.setStringAttribute('data_name', ms_domain_name) alreadyDiscoveredIps = HashMap() for hostInfo in hostsOutput: hostType = Long(hostInfo[1]).longValue() hostName = (str(hostInfo[0])).lower() try: ip = InetAddress.getByName(hostInfo[0]).getHostAddress() if netutils.isLocalIp(ip): continue cachedHostName = alreadyDiscoveredIps.get(ip) if cachedHostName != None: logger.debug('IP ', ip, ' already reported for host ' + cachedHostName, ' current host ', hostName, ' - skipping') continue else: logger.debug('Discovered IP ' + ip + ' for host ' + hostName) alreadyDiscoveredIps.put(ip, hostName) ipDomain = DomainScopeManager.getDomainByIp(ip) if not discoverUnknownIPs and ipDomain == 'unknown': logger.debug('ip: ' + ip + ' is out of probe range and will be excluded') continue if SV_TYPE_CLUSTER_NT & hostType: logger.debug('Not reporting the entry %s because it is a Cluster' % hostName) continue hostOsType = 'nt' if SV_TYPE_SERVER_UNIX & hostType: hostOsType = 'unix' oshHost = modeling.createHostOSH(ip, hostOsType) oshHost.setStringAttribute("host_hostname", hostName) OSHVResult.add(oshHost) link = modeling.createLinkOSH('member', oshMsDomain, oshHost) OSHVResult.add(link) ipOSH = modeling.createIpOSH(ip) OSHVResult.add(ipOSH) contained = modeling.createLinkOSH('contained', oshHost, ipOSH) OSHVResult.add(contained) except: errorMsg = str(sys.exc_info()[1]).strip() logger.warn('Failed to resolve host ', hostInfo[0], ' : ', errorMsg) else: message = 'Failed to discover hosts on MS Domain' logger.warn(message) logger.reportWarning(message) except: errorMsg = str(sys.exc_info()[1]).strip() logger.errorException('Failed to discovery MS Domains') errorMessage = errormessages.makeErrorMessage("msdomain", errorMsg, errormessages.ERROR_FAILED_DISCOVERING_MSDOMAIN_HOSTS) errobj = errorobject.createError(errorcodes.FAILED_DISCOVERIING_MSDOMAIN_HOST, ["msdomain", errorMsg], errorMessage) logger.reportErrorObject(errobj) return OSHVResult
from java.net import InetAddress as ip website = raw_input("Enter website name: ") #request serviced: print (ip.getByName(website)) print () print ("all address: ") for k in ip.getAllByName(website): print (k)
# # java -cp bin:../../java-router/build/deploy/lib/RawSocket.jar:../../java-router/build/deploy/lib/JythonRouter.jar:../../java-router/ThirdParty/jython2.5.1/jython.jar Main ../../java-router/code/scripts/preconfig.py ../../java-router/code/scripts/simple-ping.py from code.messy.net.ethernet import Ethertype, ArpHandler from code.messy.net.ip import IpProtocolHandler, PacketToIp, IpPacket from code.messy.net.ip.icmp import IcmpHandler from code.messy.net.ip.route import LocalSubnet from java.net import InetAddress icmp = IcmpHandler() protocol = IpProtocolHandler() protocol.register(IpPacket.Protocol.ICMP, icmp) pak2Ip = PacketToIp(protocol) arp = ArpHandler() address = InetAddress.getByName('10.0.0.2') LocalSubnet.create(address, 24, interface['eth1']) address = InetAddress.getByName('10.1.0.2'); LocalSubnet.create(address, 24, interface['eth2']) interface['eth1'].register(Ethertype.ARP, arp) interface['eth2'].register(Ethertype.ARP, arp) interface['eth1'].register(Ethertype.IP, pak2Ip) interface['eth2'].register(Ethertype.IP, pak2Ip) interface['eth1'].start() interface['eth2'].start()
{rmessage=Successful!, userid=17463581, classid=2836734, assignmentid=7902887, rcode=41} Adding an assignment with another inst {'fid': '4', 'diagnostic': '0', 'ufn': 'StevenIU', 'uln': 'GithensIU', 'username': '******', 'assignid': 'AssignmentTitle2650fcca-b96e-42bd-926e-63660076d2ad', 'aid': '56021', 'src': '9', 'cid': '2836733', 'said': '56021', 'dtstart': '20091225', 'encrypt': '0', 'assign': 'AssignmentTitle2650fcca-b96e-42bd-926e-63660076d2ad', 'uem': '*****@*****.**', 'utp': '2', 'fcmd': '2', 'ctl': 'CourseTitle46abd163-7464-4d21-a2c0-90c5af3312ab', 'dtdue': '20100101'} {rmessage=Successful!, userid=17463581, classid=2836734, assignmentid=7902888, rcode=41} """ import unittest import random import sys from org.sakaiproject.component.cover import ComponentManager from java.net import InetSocketAddress, Proxy, InetAddress from java.util import HashMap debug_proxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(InetAddress.getByName("127.0.0.1"),8008)) tiireview_serv = ComponentManager.get("org.sakaiproject.contentreview.service.ContentReviewService") class SakaiUuid(object): """My Current Jython impl doens't seem to have UUID, so re-implementing it for now""" def __init__(self): self.idmanager = ComponentManager.get("org.sakaiproject.id.api.IdManager") def uuid1(self): return self.idmanager.createUuid() uuid = SakaiUuid()
def __init__(self, IPaddress = "localhost", port = 57110): self.IPaddress = InetAddress.getByName(IPaddress) # holds IP address of OSC device to connect with self.port = port # and its listening port self.portOut = OSCPortOut(self.IPaddress, self.port) # create the connection
from code.messy.net.ethernet import Ethertype, ArpHandler, EthernetIpSupport from code.messy.net.ip import IpProtocolHandler, IpPacket from code.messy.net.ip.udp import UdpHandler from code.messy.net.ip.dhcp import DhcpHandler from code.messy.net.ip.route import LocalSubnet, RouteHandler, RoutingTable from java.net import InetAddress route = RouteHandler() eth1ip = EthernetIpSupport(interface['eth1']) eth2ip = EthernetIpSupport(interface['eth2']) address = InetAddress.getByName('10.1.0.1'); eth1network = LocalSubnet.create(address, 24, eth1ip) address = InetAddress.getByName('10.2.0.1'); eth2network = LocalSubnet.create(address, 24, eth2ip) udp1 = UdpHandler() protocol1 = IpProtocolHandler() protocol1.register(IpPacket.Protocol.UDP, udp1) protocol1.register(route) dhcp1 = DhcpHandler(eth1network) udp1.add(None, 67, dhcp1) udp2 = UdpHandler() protocol2 = IpProtocolHandler() protocol2.register(IpPacket.Protocol.UDP, udp2) protocol2.register(route) dhcp2 = DhcpHandler(eth2network) udp2.add(None, 67, dhcp2)
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() ms_domain_name = Framework.getDestinationAttribute('ms_domain_name') if not ms_domain_name: ms_domain_name = 'NULL' try: netUtil = MsNetworkUtil() hostsOutput = netUtil.doNetServerEnum('NULL', SV_TYPE_SERVER, ms_domain_name) if hostsOutput != None: discoverUnknownIPs = 1 try: strDiscoverUnknownIPs = Framework.getParameter( 'discoverUnknownIPs') discoverUnknownIPs = Boolean.parseBoolean( strDiscoverUnknownIPs) except: pass oshMsDomain = ObjectStateHolder('msdomain') oshMsDomain.setStringAttribute('data_name', ms_domain_name) alreadyDiscoveredIps = HashMap() for hostInfo in hostsOutput: hostType = Long(hostInfo[1]).longValue() hostName = (str(hostInfo[0])).lower() try: ip = InetAddress.getByName(hostInfo[0]).getHostAddress() if netutils.isLocalIp(ip): continue cachedHostName = alreadyDiscoveredIps.get(ip) if cachedHostName != None: logger.debug( 'IP ', ip, ' already reported for host ' + cachedHostName, ' current host ', hostName, ' - skipping') continue else: logger.debug('Discovered IP ' + ip + ' for host ' + hostName) alreadyDiscoveredIps.put(ip, hostName) ipDomain = DomainScopeManager.getDomainByIp(ip) if not discoverUnknownIPs and ipDomain == 'unknown': logger.debug( 'ip: ' + ip + ' is out of probe range and will be excluded') continue if SV_TYPE_CLUSTER_NT & hostType: logger.debug( 'Not reporting the entry %s because it is a Cluster' % hostName) continue hostOsType = 'nt' if SV_TYPE_SERVER_UNIX & hostType: hostOsType = 'unix' oshHost = modeling.createHostOSH(ip, hostOsType) oshHost.setStringAttribute("host_hostname", hostName) OSHVResult.add(oshHost) link = modeling.createLinkOSH('member', oshMsDomain, oshHost) OSHVResult.add(link) ipOSH = modeling.createIpOSH(ip) OSHVResult.add(ipOSH) contained = modeling.createLinkOSH('contained', oshHost, ipOSH) OSHVResult.add(contained) except: errorMsg = str(sys.exc_info()[1]).strip() logger.warn('Failed to resolve host ', hostInfo[0], ' : ', errorMsg) else: message = 'Failed to discover hosts on MS Domain' logger.warn(message) logger.reportWarning(message) except: errorMsg = str(sys.exc_info()[1]).strip() logger.errorException('Failed to discovery MS Domains') errorMessage = errormessages.makeErrorMessage( "msdomain", errorMsg, errormessages.ERROR_FAILED_DISCOVERING_MSDOMAIN_HOSTS) errobj = errorobject.createError( errorcodes.FAILED_DISCOVERIING_MSDOMAIN_HOST, ["msdomain", errorMsg], errorMessage) logger.reportErrorObject(errobj) return OSHVResult
def __init__(self, config): if isinstance(config, basestring): self.config = json.loads(config.decode('utf-8')) else: self.config = config self.runtime = {} #TODO: ugly ugly initialization all around, review, make it sane clusterName = "elasticsearch" host = "localhost" port = 9300 if "host" in self.config: host = self.config["host"] else: host = "localhost" if "port" in self.config: port = self.config["port"] else: port = "9300" if "bulkActions" not in self.config: self.config["bulkActions"] = 1000 if "bulkSize" not in self.config: self.config["bulkSize"] = 107374182400 if "flushInterval" not in self.config: self.config["flushInterval"] = 60000 if "concurrentRequests" not in self.config: self.config["concurrentRequests"] = 1 if "actionRetryTimeout" not in self.config: self.config["actionRetryTimeout"] = 5 if "type" not in self.config: self.config["type"] = "logs" if "indexPrefix" not in self.config: self.config["indexPrefix"] = "sampleindex" if "indexSuffix" not in self.config: self.config["indexSuffix"] = "-%Y.%m.%d" logger.debug("Initializing elasticsearch output %s: %s", self.config["indexPrefix"], json.dumps("self.config")) self.config["settings"] = Settings.builder(); if "options" not in self.config: self.config["options"] = {} if "cluster" in self.config: self.config["options"]["cluster.name"] = self.config["cluster"] else: self.config["options"]["cluster.name"] = "elasticsearch" else: if "cluster.name" not in self.config["options"]: if "cluster" in self.config: self.config["options"]["cluster.name"] = self.config["cluster"] else: self.config["options"]["cluster.name"] = "elasticsearch" for setting in self.config["options"]: value = self.config["options"][setting] logger.info("Setting Elasticsearch options: %s = %s", setting, value) self.config["settings"].put(setting, value) self.config["settings"].build() self.runtime["client"] = PreBuiltTransportClient(self.config["settings"].build(), []) if "host" in self.config: address = InetSocketTransportAddress(InetAddress.getByName(host), int(port)) self.runtime["client"].addTransportAddress(address) if "hosts" in self.config: for hostport in self.config["hosts"]: host, port = hostport.split(":") address = InetSocketTransportAddress(InetAddress.getByName(host), int(port)) logger.info("Setting Elasticsearch host: %s = %s", host, port) self.runtime["client"].addTransportAddress(address) self.readyBulk() self.runtime["indices"] = {}
def resolveHostIp(hostName): try: return InetAddress.getByName(hostName).getHostAddress() except UnknownHostException: logger.debug("Failed to resolve IP for host '%s'" % hostName)
Adding an assignment with another inst {'fid': '4', 'diagnostic': '0', 'ufn': 'StevenIU', 'uln': 'GithensIU', 'username': '******', 'assignid': 'AssignmentTitle2650fcca-b96e-42bd-926e-63660076d2ad', 'aid': '56021', 'src': '9', 'cid': '2836733', 'said': '56021', 'dtstart': '20091225', 'encrypt': '0', 'assign': 'AssignmentTitle2650fcca-b96e-42bd-926e-63660076d2ad', 'uem': '*****@*****.**', 'utp': '2', 'fcmd': '2', 'ctl': 'CourseTitle46abd163-7464-4d21-a2c0-90c5af3312ab', 'dtdue': '20100101'} {rmessage=Successful!, userid=17463581, classid=2836734, assignmentid=7902888, rcode=41} """ import unittest import random import sys from org.sakaiproject.component.cover import ComponentManager from java.net import InetSocketAddress, Proxy, InetAddress from java.util import HashMap debug_proxy = Proxy( Proxy.Type.HTTP, InetSocketAddress(InetAddress.getByName("127.0.0.1"), 8008)) tiireview_serv = ComponentManager.get( "org.sakaiproject.contentreview.service.ContentReviewService") class SakaiUuid(object): """My Current Jython impl doens't seem to have UUID, so re-implementing it for now""" def __init__(self): self.idmanager = ComponentManager.get( "org.sakaiproject.id.api.IdManager") def uuid1(self): return self.idmanager.createUuid()