コード例 #1
0
    def reportWebDir(self, web_app, parent_osh, app_pools_map=None, webservice_ext_filter = []):
        """

        :param web_app:
        :type web_app: iis.WebApplication
        :param parent_osh:
        :type parent_osh:
        :param app_pools_map:
        :type app_pools_map:
        :return:
        :rtype:
        """
        oshs = []
        osh = self._builder.buildApplication(web_app)
        osh.setContainer(parent_osh)
        oshs.append(osh)
        if app_pools_map:
            app_pool_osh = app_pools_map.get(web_app.app_pool_name)
            if app_pool_osh:
                oshs.append(modeling.createLinkOSH("deployed", osh, app_pool_osh))
        if web_app.config_files:
            oshs.extend(self.reportConfigFiles(web_app.config_files, osh))
            #report webservice using webservice config file
            oshs.extend(self.reportWebServices(web_app.config_files, osh, webservice_ext_filter))
        if web_app.virtual_dirs:
            func = partial(self.reportVirtualDir, parent_osh=osh)
            oshs.extend(iflatten(ifilter(None, imap(func, web_app.virtual_dirs))))
        return oshs
コード例 #2
0
    def reportTopology(self, app_pools_list, web_sites_list, parentOsh, iis_version=None, webservice_ext_filter=[]):
        """

        :param web_sites_list: List of WebSites which was discovered
        :type web_sites_list: list[iis.Site]
        :param parentOsh: parent OSH for each website
        :type parentOsh: ObjectStateHolder
        :return: list[ObjectStateHolder]
        :rtype: list[ObjectStateHolder]
        """
        result = []
        apppool_map = self.reportAppPools(app_pools_list, parentOsh)
        sites_map = self.reportWebSites(web_sites_list, parentOsh, iis_version)
        result.extend(sites_map.values())
        result.extend(apppool_map.values())

        # report VirtualDir and WebDirs(WebApplication)
        for site in web_sites_list:
            web_site_osh = sites_map.get(site.name)
            if not site.is_ftp():
                # report root web dir
                root_web_dir = iis.WebApplication("Root", "/", site.path, site.config_files)
                root_osh = self._builder.buildApplication(root_web_dir)
                root_osh.setContainer(web_site_osh)
                result.append(root_osh)
                if apppool_map:
                    app_pool_osh = apppool_map.get(site.app_pool.name)
                    if app_pool_osh:
                        result.append(modeling.createLinkOSH("deployed", root_osh, app_pool_osh))

                # report config files
                result.extend(self.reportConfigFiles(site.config_files, root_osh))

                # report virtual dirs
                report_virtual_dirs = partial(self.reportVirtualDir, parent_osh=root_osh)
                result.extend(iflatten(ifilter(None, imap(report_virtual_dirs, site.virtual_dirs))))

                # report Webdirs = WebApplications
                report_web_application = partial(self.reportWebDir, parent_osh=root_osh, app_pools_map=apppool_map, webservice_ext_filter=webservice_ext_filter)
                result.extend(iflatten(ifilter(None, imap(report_web_application, site.web_applications))))

            bindings = flatten(
                ifilter(None, imap(lambda binding: binding[1].lower() in ['http', 'https', 'ftp'] and binding[2],
                                   site.bindings)))
            result.extend(self.reportBindings(bindings, web_site_osh, parentOsh))

        return result