def register_from_pack(self, pack_dir):
        """
        Register all the policies from the provided pack.
        :return: Number of policies registered.

        :rtype: ``int``
        """
        pack_dir = pack_dir[:-1] if pack_dir.endswith("/") else pack_dir
        _, pack = os.path.split(pack_dir)

        policies_dir = self._pack_loader.get_content_from_pack(
            pack_dir=pack_dir, content_type="policies"
        )

        # Register pack first
        self.register_pack(pack_name=pack, pack_dir=pack_dir)

        registered_count = 0
        if not policies_dir:
            return registered_count

        LOG.debug("Registering policies from pack %s, dir: %s", pack, policies_dir)

        try:
            policies = self._get_policies_from_pack(policies_dir=policies_dir)
            registered_count = self._register_policies_from_pack(
                pack=pack, policies=policies
            )
        except Exception as e:
            if self._fail_on_failure:
                raise e

            LOG.exception("Failed registering all policies from pack: %s", policies_dir)
            return registered_count

        return registered_count

        Register all the policies from the provided pack.
        :return: Number of policies registered.

        :rtype: ``int``
        
st2common/st2common/bootstrap/policiesregistrar.py