Esempio n. 1
0
 def _do_command(self):
     """
     Executes the command.
     """
     self._validate_options()
     if self.options.cacert and self.options.clicert and self.options.clikey:
         self.yfetch = YumRepoGrinder(self.options.label, self.options.url, \
                             self.parallel, cacert=self.options.cacert, \
                             clicert=self.options.clicert, clikey=self.options.clikey)
     else:
         self.yfetch = YumRepoGrinder(self.options.label, self.options.url, \
                             self.parallel)
     if self.options.dir:
         self.yfetch.fetchYumRepo(self.options.dir)
     else:
         self.yfetch.fetchYumRepo()
Esempio n. 2
0
class RepoDriver(CliDriver):
    parallel = 5
    def __init__(self):
        usage = "usage: %prog yum [OPTIONS]"
        shortdesc = "Fetches content from a yum repo."
        desc = "yum"
        CliDriver.__init__(self, "yum", usage, shortdesc, desc)
        GrinderLog.setup(self.debug)

        self.parser.add_option("--label", dest="label",
                          help="Repo label")
        self.parser.add_option("--url", dest="url",
                          help="Repo URL to fetch the content bits.")
        self.parser.add_option("--cacert", dest="cacert",
                          help="Path location to CA Certificate.")
        self.parser.add_option("--clicert", dest="clicert",
                          help="Path location to Client SSl Certificate.")
        self.parser.add_option("--clikey", dest="clikey",
                          help="Path location to Client Certificate Key.")
        self.parser.add_option("--parallel", dest="parallel",
                          help="Thread count to fetch the bits in parallel. Defaults to 5")
        self.parser.add_option("--dir", dest="dir",
                          help="Directory path to store the fetched content. Defaults to Current working Directory")

    def _validate_options(self):
        if not self.options.label:
            print("repo label is required. Try --help.")
            sys.exit(-1)

        if not self.options.url:
            print("No Url specific to fetch content. Try --help")
            sys.exit(-1)

        if self.options.parallel:
            self.parallel = self.options.parallel

    def _do_command(self):
        """
        Executes the command.
        """
        self._validate_options()
        if self.options.cacert and self.options.clicert and self.options.clikey:
            self.yfetch = YumRepoGrinder(self.options.label, self.options.url, \
                                self.parallel, cacert=self.options.cacert, \
                                clicert=self.options.clicert, clikey=self.options.clikey)
        else:
            self.yfetch = YumRepoGrinder(self.options.label, self.options.url, \
                                self.parallel)
        if self.options.dir:
            self.yfetch.fetchYumRepo(self.options.dir)
        else:
            self.yfetch.fetchYumRepo()

    def stop(self):
        self.yfetch.stop()