def getAction(table_name, action, useMultiple=False): try: act = SNHelper.getAction(table_name, action) debugPrint(4, '[getAction] Got SN action <%s> for table <%s> and UCMDB action <%s>' % (act, table_name, action)) return act except: excInfo = logger.prepareJythonStackTrace('') logger.warn('[getAction] Exception: <%s>' % excInfo) pass
def getStub(SNConnPropMap, table_name): try: username = SNConnPropMap.get('username') password = SNConnPropMap.get('password') proxyServer = SNConnPropMap.get('proxyServer') proxyPort = SNConnPropMap.get('proxyPort') logger.info('Create SN Stub for table:', table_name) stub = SNHelper.getStub(SNConnPropMap, table_name) if not stub: logger.error('[getStub] Unable to get SN API stub for table <%s>' % table_name) raise Exception('[getStub] Unable to get SN API stub for table <%s>' % table_name) return stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED, Boolean.FALSE) #Set basic authentication basicAuthentication = HttpTransportProperties.Authenticator() basicAuthentication.setUsername(username) basicAuthentication.setPassword(password) basicAuthentication.setPreemptiveAuthentication(1) stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuthentication) stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(REQUEST_TIMEOUT * 1000) #Set proxy if proxyServer and proxyPort: proxyProperties = HttpTransportProperties.ProxyProperties() proxyProperties.setProxyName(proxyServer) proxyProperties.setProxyPort(int(proxyPort)) stub._getServiceClient().getOptions().setProperty(HTTPConstants.PROXY, proxyProperties) debugPrint(3, '[getStub] Setting proxy server <%s:%s>' % (proxyServer, proxyPort)) debugPrint(3, '[getStub] Got SN API stub for table <%s>' % table_name) return stub except Exception, ex: raise Exception('[getStub] ' + ex.getMessage()) excInfo = logger.prepareJythonStackTrace('') logger.warn('[getStub] Exception: <%s>' % excInfo) pass