def get_web_configs(self, physical_path_of_app, shell, webservice_ext_filter): fs = file_system.createFileSystem(shell) configs = [] try: file_attr = (file_topology.BASE_FILE_ATTRIBUTES + [ file_topology.FileAttrs.CONTENT, file_topology.FileAttrs.LAST_MODIFICATION_TIME ]) logger.debug("try to get webservice from path:", physical_path_of_app) files = fs.getFiles( physical_path_of_app, filters=[file_system.ExtensionsFilter(webservice_ext_filter)], fileAttrs=[ file_topology.FileAttrs.NAME, file_topology.FileAttrs.PATH ]) for webservicefile in files: logger.debug("getting webservice file:", webservicefile.path) file = fs.getFile(webservicefile.path, file_attr) if file: content = file.content config_file = iis.ConfigFile( webservicefile.path, content, file.lastModificationTime(), ) configs.append(config_file) webconfig_path = physical_path_of_app + "\web.config" logger.debug("try to get web.config file from path:", webconfig_path) webconfig = fs.getFile(webconfig_path, file_attr) if webconfig: content = webconfig.content content = content.strip() xmlContentStartIndex = content.find('<?xml') if xmlContentStartIndex != -1: content = content[xmlContentStartIndex:] # Lazy intilization of old code to prevent cyclic dependencies from NTCMD_IIS import WebConfig content = WebConfig.replacePasswords(content) db_datasources = self.get_db_datasources(content) config_file = iis.ConfigFile(webconfig_path, content, webconfig.lastModificationTime(), db_datasources) configs.append(config_file) except: logger.debug("Unable to discover %s" % physical_path_of_app) #logger.debugException("") #logger.reportWarning("Unable to discover some of config files") return configs
def get_web_configs(self, webconfig_path_list, shell, webservice_ext_filter): fs = file_system.createFileSystem(shell) configs = [] for webconfig_path in webconfig_path_list: try: webconfig_path = webconfig_path.find("%") != -1 and shell_interpreter.dereference_string(shell, webconfig_path) or webconfig_path default_configs = map( lambda obj: obj.find("%") != -1 and shell_interpreter.dereference_string(shell, obj) or obj, self.DEFAULT_WEB_CONFIGURATION_LOCATIONS) if not webconfig_path in default_configs and fs.exists(webconfig_path): file_attr = (file_topology.BASE_FILE_ATTRIBUTES + [file_topology.FileAttrs.CONTENT, file_topology.FileAttrs.LAST_MODIFICATION_TIME]) logger.debug("getting config file:", webconfig_path) resource_path = '' match = re.match('(.*)\\\\.*', webconfig_path) if match: resource_path = match.group(1) logger.debug("getting config file path:", resource_path) files = fs.getFiles(resource_path, filters = [file_system.ExtensionsFilter(webservice_ext_filter)], fileAttrs = [file_topology.FileAttrs.NAME, file_topology.FileAttrs.PATH]) for webservicefile in files: logger.debug("getting webservice file:", webservicefile.path) file = fs.getFile(webservicefile.path, file_attr) if file: content = file.content config_file = iis.ConfigFile(webservicefile.path, content, file.lastModificationTime(),) configs.append(config_file) webconfig = fs.getFile(webconfig_path, file_attr) if webconfig: content = webconfig.content content = content.strip() xmlContentStartIndex = content.find('<?xml') if xmlContentStartIndex != -1: content = content[xmlContentStartIndex:] # Lazy intilization of old code to prevent cyclic dependencies from NTCMD_IIS import WebConfig content = WebConfig.replacePasswords(content) db_datasources = self.get_db_datasources(content) config_file = iis.ConfigFile(webconfig_path, content, webconfig.lastModificationTime(), db_datasources) configs.append(config_file) except: logger.warn("Unable to discover %s" % webconfig_path) logger.debugException("") logger.reportWarning("Unable to discover some of config files") return configs
def get_web_configs(self, physical_path_of_app, shell, webservice_ext_filter): fs = file_system.createFileSystem(shell) configs = [] try: file_attr = file_topology.BASE_FILE_ATTRIBUTES + [ file_topology.FileAttrs.CONTENT, file_topology.FileAttrs.LAST_MODIFICATION_TIME, ] logger.debug("try to get webservice from path:", physical_path_of_app) files = fs.getFiles( physical_path_of_app, filters=[file_system.ExtensionsFilter(webservice_ext_filter)], fileAttrs=[file_topology.FileAttrs.NAME, file_topology.FileAttrs.PATH], ) for webservicefile in files: logger.debug("getting webservice file:", webservicefile.path) file = fs.getFile(webservicefile.path, file_attr) if file: content = file.content config_file = iis.ConfigFile(webservicefile.path, content, file.lastModificationTime()) configs.append(config_file) webconfig_path = physical_path_of_app + "\web.config" logger.debug("try to get web.config file from path:", webconfig_path) webconfig = fs.getFile(webconfig_path, file_attr) if webconfig: content = webconfig.content content = content.strip() xmlContentStartIndex = content.find("<?xml") if xmlContentStartIndex != -1: content = content[xmlContentStartIndex:] # Lazy intilization of old code to prevent cyclic dependencies from NTCMD_IIS import WebConfig content = WebConfig.replacePasswords(content) db_datasources = self.get_db_datasources(content) config_file = iis.ConfigFile(webconfig_path, content, webconfig.lastModificationTime(), db_datasources) configs.append(config_file) except: logger.debug("Unable to discover %s" % physical_path_of_app) # logger.debugException("") # logger.reportWarning("Unable to discover some of config files") return configs
def get_web_configs(self, webconfig_path_list, shell, webservice_ext_filter): fs = file_system.createFileSystem(shell) configs = [] for webconfig_path in webconfig_path_list: try: webconfig_path = ( webconfig_path.find("%") != -1 and shell_interpreter.dereference_string(shell, webconfig_path) or webconfig_path ) default_configs = map( lambda obj: obj.find("%") != -1 and shell_interpreter.dereference_string(shell, obj) or obj, self.DEFAULT_WEB_CONFIGURATION_LOCATIONS, ) if not webconfig_path in default_configs and fs.exists(webconfig_path): file_attr = file_topology.BASE_FILE_ATTRIBUTES + [ file_topology.FileAttrs.CONTENT, file_topology.FileAttrs.LAST_MODIFICATION_TIME, ] logger.debug("getting config file:", webconfig_path) resource_path = "" match = re.match("(.*)\\\\.*", webconfig_path) if match: resource_path = match.group(1) logger.debug("getting config file path:", resource_path) files = fs.getFiles( resource_path, filters=[file_system.ExtensionsFilter(webservice_ext_filter)], fileAttrs=[file_topology.FileAttrs.NAME, file_topology.FileAttrs.PATH], ) for webservicefile in files: logger.debug("getting webservice file:", webservicefile.path) file = fs.getFile(webservicefile.path, file_attr) if file: content = file.content config_file = iis.ConfigFile(webservicefile.path, content, file.lastModificationTime()) configs.append(config_file) webconfig = fs.getFile(webconfig_path, file_attr) if webconfig: content = webconfig.content content = content.strip() xmlContentStartIndex = content.find("<?xml") if xmlContentStartIndex != -1: content = content[xmlContentStartIndex:] # Lazy intilization of old code to prevent cyclic dependencies from NTCMD_IIS import WebConfig content = WebConfig.replacePasswords(content) db_datasources = self.get_db_datasources(content) config_file = iis.ConfigFile( webconfig_path, content, webconfig.lastModificationTime(), db_datasources ) configs.append(config_file) except: logger.warn("Unable to discover %s" % webconfig_path) logger.debugException("") logger.reportWarning("Unable to discover some of config files") return configs