def register_from_packs(self, base_dirs):
        """
        Discover all the packs in the provided directory and register policies from all of the
        discovered packs.

        :return: Number of policies registered.
        :rtype: ``int``
        """
        # Register packs first
        self.register_packs(base_dirs=base_dirs)

        registered_count = 0
        content = self._pack_loader.get_content(
            base_dirs=base_dirs, content_type="policies"
        )

        for pack, policies_dir in six.iteritems(content):
            if not policies_dir:
                LOG.debug("Pack %s does not contain policies.", pack)
                continue
            try:
                LOG.debug(
                    "Registering policies from pack %s:, dir: %s", pack, policies_dir
                )
                policies = self._get_policies_from_pack(policies_dir)
                count = self._register_policies_from_pack(pack=pack, policies=policies)
                registered_count += count
            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

        Discover all the packs in the provided directory and register policies from all of the
        discovered packs.

        :return: Number of policies registered.
        :rtype: ``int``
        
st2common/st2common/bootstrap/policiesregistrar.py