Automated Paсkage versions update for tags

Module repos.py
 - ReposInfo(), walks mirror using HTTP and builds
   all repos map available
 - RepoManager(), using repos map builds package versions map
   either for specific tags or for all of them

Fixes:
 - Progress class clears line remainder on change

Utils:
 - Download GZ file into memory
 - TGZ file interface, CRU (no deletion)

Change-Id: Ifdb37aa4b68fb25f642b2089cf16cd242ed25a0b
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/packages/__init__.py b/cfg_checker/modules/packages/__init__.py
index a4a81bd..f88ce51 100644
--- a/cfg_checker/modules/packages/__init__.py
+++ b/cfg_checker/modules/packages/__init__.py
@@ -1,4 +1,5 @@
 from cfg_checker.helpers import args_utils
+from cfg_checker.modules.packages.repos import RepoManager
 
 import checker
 
@@ -29,6 +30,36 @@
         help="CSV filename to save report"
     )
 
+    pkg_repos = pkg_subparsers.add_parser(
+        'versions',
+        help="Parse versions at given URL and create local map"
+    )
+    pkg_repos.add_argument(
+        '--list-tags',
+        action="store_true", default=False,
+        help="Just list tags available in mirror"
+    )
+    pkg_repos.add_argument(
+        '--url',
+        metavar='repo_url', default="http://mirror.mirantis.com",
+        help="URL for repos, default: http://mirror.mirantis.com"
+    )
+    pkg_repos.add_argument(
+        '--tag',
+        metavar='repo_tag', default=None,
+        help="Repository tag to process packages from. Default: "
+        "All url's root folder tags"
+    )
+    pkg_repos.add_argument(
+        '--build-repos',
+        action="store_true", default=False,
+        help="Conduct build stage before working with tags"
+    )
+    pkg_repos.add_argument(
+        '--gen-desc',
+        action="store_true", default=False,
+        help="Save pkg descriptions while parsing"
+    )
     return _parser
 
 
@@ -48,3 +79,32 @@
     pChecker.collect_packages()
     # report it
     pChecker.create_report(_filename, rtype=_type, full=args.full)
+
+
+def do_versions(args):
+    """Builds tagged repo structure and parses Packages.gz files
+
+    :args: - parser arguments
+    :return: - no return value
+    """
+    # Get the list of tags for the url
+    r = RepoManager()
+    if args.build_repos:
+        # if tag is supplied, use it
+        if args.tag:
+            r.action_for_tag(args.url, args.tag, action="build")
+        else:
+            r.build_repos(args.url)
+
+    # if tag is supplied, use it
+    if args.tag:
+        # Process only this tag
+        r.action_for_tag(
+            args.url,
+            args.tag,
+            action="fetch",
+            descriptions=args.gen_desc
+        )
+    else:
+        # All of them
+        r.parse_repos()