Ejemplo n.º 1
0
    def get_path_node(self, site_name, virtual_path):
        """
        Returns node of virtual path for server tree
        """
        vdirs = self.get_subvirtualdirectories(site_name, virtual_path)
        for v in vdirs:
            if v.path == virtual_path:
                physical_path = os.path.abspath(v.physical_path)
                name = os.path.basename(physical_path)
                zoo_config_path = os.path.join(physical_path, ".zoo")
                node = {
                    "name": name,
                    "path": combine_virtual_path(site_name, virtual_path),
                    "physical_path": physical_path,
                    "type": "virtual directory",
                    'is_virtual': True,
                    "config": get_zoo_config(zoo_config_path)
                }
                return node

        physical_path = os.path.abspath(self.map_path(site_name, virtual_path))
        name = os.path.basename(physical_path)
        zoo_config_path = os.path.join(physical_path, ".zoo")
        node = {
            "name": name,
            "path": combine_virtual_path(site_name, virtual_path),
            "physical_path": physical_path,
            "type": "directory",
            "config": get_zoo_config(zoo_config_path)
        }
        return node
Ejemplo n.º 2
0
Archivo: iis.py Proyecto: perldev/zoo
    def get_path_node(self, site_name, virtual_path):
        """
        Returns node of virtual path for server tree
        """
        vdirs = self.get_subvirtualdirectories(site_name, virtual_path)
        for v in vdirs:
            if v.path == virtual_path:
                physical_path = os.path.abspath(v.physical_path)
                name = os.path.basename(physical_path)
                zoo_config_path = os.path.join(physical_path, ".zoo")
                node = {
                    "name": name,
                    "path": combine_virtual_path(site_name, virtual_path),
                    "physical_path": physical_path,
                    "type": "virtual directory",
                    'is_virtual': True,
                    "config": get_zoo_config(zoo_config_path)
                }
                return node

        physical_path = os.path.abspath(self.map_path(site_name, virtual_path))
        name = os.path.basename(physical_path)
        zoo_config_path = os.path.join(physical_path, ".zoo")
        node = {
            "name": name,
            "path": combine_virtual_path(site_name, virtual_path),
            "physical_path": physical_path,
            "type": "directory",
            "config": get_zoo_config(zoo_config_path)
        }
        return node
Ejemplo n.º 3
0
Archivo: iis.py Proyecto: perldev/zoo
    def map_path_get_paths(self, apps_collection, virt_path):
        """
        Helper to search app with virtual_path in apps collections.
        """
        result = ""
        found_virt_path = ""

        for ii in range(apps_collection.Count):
            app_prop = apps_collection[ii].Properties

            app_path = app_prop["path"].Value
            if virt_path.lower().startswith(app_path.lower()):
                vdir_collection = apps_collection[ii].Collection
                for iii in range(vdir_collection.Count):
                    vdir_prop = vdir_collection[iii].Properties
                    temp = combine_virtual_path(
                        app_path,
                        vdir_prop["path"].Value)
                    if virt_path.lower() == temp.lower():
                        result = vdir_prop["physicalPath"].Value
                        result = self.core.expandvars(result)
                        # exactly matched virtual dir
                        return result, virt_path

                    if virt_path.lower().startswith(temp.lower()):
                        result = vdir_prop["physicalPath"].Value
                        result = self.core.expandvars(result)
                        found_virt_path = temp
                # do not search in the other apps
                return result, found_virt_path

        # not found app
        return result, found_virt_path
Ejemplo n.º 4
0
    def map_path_get_paths(self, apps_collection, virt_path):
        """
        Helper to search app with virtual_path in apps collections.
        """
        result = ""
        found_virt_path = ""

        for ii in range(apps_collection.Count):
            app_prop = apps_collection[ii].Properties

            app_path = app_prop["path"].Value
            if virt_path.lower().startswith(app_path.lower()):
                vdir_collection = apps_collection[ii].Collection
                for iii in range(vdir_collection.Count):
                    vdir_prop = vdir_collection[iii].Properties
                    temp = combine_virtual_path(app_path,
                                                vdir_prop["path"].Value)
                    if virt_path.lower() == temp.lower():
                        result = vdir_prop["physicalPath"].Value
                        result = self.core.expandvars(result)
                        # exactly matched virtual dir
                        return result, virt_path

                    if virt_path.lower().startswith(temp.lower()):
                        result = vdir_prop["physicalPath"].Value
                        result = self.core.expandvars(result)
                        found_virt_path = temp
                # do not search in the other apps
                return result, found_virt_path

        # not found app
        return result, found_virt_path
    def process_webserver_parameters(self, parameters):
        """
        для Application
        расчитать спецефические переемнные SITE_NAME, SITE_BINDING, CREATE_APP, PHYSICAL_PATH
        :param parameters:
        :raise Exception:
        """

        if parameters.get(KnownParameters.CREATE_SITE.value, False):
            if not all([
                (KnownParameters.SITE_NAME.value in parameters),
                # (KnownParameters.SITE_PATH.value in parameters),
                (KnownParameters.SITE_BINDING.value in parameters)
            ]):
                raise Exception("Please specify all parameters for create-site")

            self.core.api.os.web_server.site_create_from_dict(parameters)

        # pool
        if parameters.get(KnownParameters.CREATE_POOL.value, False):
            self.core.api.os.web_server.pool_create_from_dict(parameters)

        # application
        if parameters.get(KnownParameters.CREATE_APP.value, False):
            if not all([
                (KnownParameters.SITE_NAME.value in parameters),
                (KnownParameters.APP_NAME.value in parameters),
            ]):
                raise Exception("Please specify all parameters for create-app")

            self.core.api.os.web_server.application_create_from_dict(parameters)

        if KnownParameters.SITE_NAME.value in parameters:
            # set / if doesn't exist
            parameters[KnownParameters.APP_NAME.value] = parameters.get(KnownParameters.APP_NAME.value, "/")

            virtual_path = combine_virtual_path(
                parameters[KnownParameters.SITE_NAME.value],
                parameters.get(KnownParameters.APP_NAME.value))

            physical_path = self.core.api.os.web_server.map_webserver_path(virtual_path)

            if physical_path is None:
                raise Exception("Can't get physical_path for '{0}'".format(virtual_path))

            parameters[KnownParameters.PHYSICAL_PATH.value] = physical_path
Ejemplo n.º 6
0
Archivo: iis.py Proyecto: perldev/zoo
 def get_site_node(self, site_name):
     """
     Returns site node as dict for server tree
     """
     site = self.get_site(site_name)
     if site:
         physical_path = site.default_app["physicalPath"]
         zoo_config_path = os.path.join(physical_path, ".zoo")
         node = {
             "name": site_name,
             "path": combine_virtual_path(site_name, '/'),
             "physical_path": physical_path,
             "type": "site",
             "config": get_zoo_config(zoo_config_path),
             'bindings': site.bindings,
             'urls': site.urls
         }
     else:
         node = None
     return node
Ejemplo n.º 7
0
 def get_site_node(self, site_name):
     """
     Returns site node as dict for server tree
     """
     site = self.get_site(site_name)
     if site:
         physical_path = site.default_app["physicalPath"]
         zoo_config_path = os.path.join(physical_path, ".zoo")
         node = {
             "name": site_name,
             "path": combine_virtual_path(site_name, '/'),
             "physical_path": physical_path,
             "type": "site",
             "config": get_zoo_config(zoo_config_path),
             'bindings': site.bindings,
             'urls': site.urls
         }
     else:
         node = None
     return node
Ejemplo n.º 8
0
Archivo: iis.py Proyecto: perldev/zoo
    def get_directories(self, site_name, virt_path):
        """
        Returns list of dict with child physical directories of virtual path
        """
        logging.debug("site_name='{0}' virt_path='{1}'".format(site_name, virt_path))
        result = []

        if site_name is None and virt_path is None:
            # return list of sites
            core = Core.get_instance()
            sites = core.api.os.web_server.get_list_of_sites()
            for site in sites:
                # physical_path = self.map_path(site.name, "/")  # slow
                physical_path = site.default_app["physicalPath"]
                zoo_config_path = os.path.join(physical_path, ".zoo")
                result.append(
                    {
                        "name": site.name,
                        "path": site.name + '/',
                        "physical_path": physical_path,
                        "type": "site",
                        "config": get_zoo_config(zoo_config_path),
                        "bindings": site.bindings,
                        'urls': site.urls
                    }
                )

        else:
            # check site exists
            test_site = self.get_site(site_name)
            if test_site:
                # site exists
                root_path = self.map_path(site_name, virt_path)
                sub_dirs = self.get_subdirectories(root_path)

                for d in sub_dirs:
                    physical_path = os.path.abspath(d)
                    name = os.path.basename(physical_path)
                    zoo_config_path = os.path.join(physical_path, ".zoo")
                    result.append(
                        {
                            "name": name,
                            "path": combine_virtual_path(site_name, combine_virtual_path(virt_path, name)),
                            "physical_path": physical_path,
                            "type": "directory",
                            "config": get_zoo_config(zoo_config_path)
                        }
                    )

                vdirs = self.get_subvirtualdirectories(site_name, virt_path)

                for vdir in vdirs:
                    physical_path = vdir.physical_path
                    name = os.path.basename(vdir.path[:-1])
                    zoo_config_path = os.path.join(physical_path, ".zoo")

                    self.remove_by_name(result, name)

                    result.append(
                        {
                            "name": name,
                            "path": combine_virtual_path(site_name, vdir.path),
                            "physical_path": physical_path,
                            "type": "virtual directory",
                            'is_virtual': True,
                            "config": get_zoo_config(zoo_config_path)
                        }
                    )
            else:
                # site not exists
                result = []

        result = sorted(result, key=lambda d: d["name"].lower())

        return result
Ejemplo n.º 9
0
    def get_directories(self, site_name, virt_path):
        """
        Returns list of dict with child physical directories of virtual path
        """
        logging.debug("site_name='{0}' virt_path='{1}'".format(
            site_name, virt_path))
        result = []

        if site_name is None and virt_path is None:
            # return list of sites
            core = Core.get_instance()
            sites = core.api.os.web_server.get_list_of_sites()
            for site in sites:
                # physical_path = self.map_path(site.name, "/")  # slow
                physical_path = site.default_app["physicalPath"]
                zoo_config_path = os.path.join(physical_path, ".zoo")
                result.append({
                    "name": site.name,
                    "path": site.name + '/',
                    "physical_path": physical_path,
                    "type": "site",
                    # "config": get_zoo_config(zoo_config_path),
                    "bindings": site.bindings,
                    'urls': site.urls
                })

        else:
            # check site exists
            test_site = self.get_site(site_name)
            if test_site:
                # site exists
                root_path = self.map_path(site_name, virt_path)
                sub_dirs = self.get_subdirectories(root_path)

                for d in sub_dirs:
                    physical_path = os.path.abspath(d)
                    name = os.path.basename(physical_path)
                    zoo_config_path = os.path.join(physical_path, ".zoo")
                    result.append({
                        "name":
                        name,
                        "path":
                        combine_virtual_path(
                            site_name, combine_virtual_path(virt_path, name)),
                        "physical_path":
                        physical_path,
                        "type":
                        "directory",
                        "config":
                        get_zoo_config(zoo_config_path)
                    })

                vdirs = self.get_subvirtualdirectories(site_name, virt_path)

                for vdir in vdirs:
                    physical_path = vdir.physical_path
                    name = os.path.basename(vdir.path[:-1])
                    zoo_config_path = os.path.join(physical_path, ".zoo")

                    self.remove_by_name(result, name)

                    result.append({
                        "name":
                        name,
                        "path":
                        combine_virtual_path(site_name, vdir.path),
                        "physical_path":
                        physical_path,
                        "type":
                        "virtual directory",
                        'is_virtual':
                        True,
                        "config":
                        get_zoo_config(zoo_config_path)
                    })
            else:
                # site not exists
                result = []

        result = sorted(result, key=lambda d: d["name"].lower())

        return result