def check_for_package(connection, reponame, package):
        '''
        list packages in a repository
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "p")
        RHUIManager.select_one(connection, reponame)
        Expect.expect(connection, "\(blank line for no filter\):")
        Expect.enter(connection, package)

        pattern = re.compile('.*only\.\r\n(.*)\r\n-+\r\nrhui\s* \(repo\)\s* =>',
                             re.DOTALL)
        ret = Expect.match(connection, pattern, grouplist=[1])[0]
        reslist = map(lambda x: x.strip(), ret.split("\r\n"))
        print reslist
        packagelist = []
        for line in reslist:
            if line == '':
                continue
            if line == 'Packages:':
                continue
            if line == 'No packages found that match the given filter.':
                continue
            if line == 'No packages in the repository.':
                continue
            packagelist.append(line)

        Expect.enter(connection, 'q')
        return packagelist
Пример #2
0
    def check_for_package(connection, reponame, package):
        '''
        list packages in a repository
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "p")
        RHUIManager.select_one(connection, reponame)
        Expect.expect(connection, "\(blank line for no filter\):")
        Expect.enter(connection, package)

        pattern = re.compile(
            '.*only\.\r\n(.*)\r\n-+\r\nrhui\s* \(repo\)\s* =>', re.DOTALL)
        ret = Expect.match(connection, pattern, grouplist=[1])[0]
        reslist = map(lambda x: x.strip(), ret.split("\r\n"))
        print reslist
        packagelist = []
        for line in reslist:
            if line == '':
                continue
            if line == 'Packages:':
                continue
            if line == 'No packages found that match the given filter.':
                continue
            if line == 'No packages in the repository.':
                continue
            packagelist.append(line)

        Expect.enter(connection, 'q')
        return packagelist
 def associate_repo_cds(connection, clustername, repolist):
     '''
     associate a repository with a CDS cluster
     '''
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "s")
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(connection, "The following repositories will be associated with the " + clustername + " cluster:",
                                    repolist, ["Red Hat Repositories", "Custom Repositories"])
     RHUIManager.quit(connection)
 def delete_cds(connection, clustername, cdslist, force=False):
     '''
     unregister (delete) a CDS instance from the RHUI
     '''
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "d")
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select(connection, cdslist)
     RHUIManager.proceed_with_check(connection, "The following CDS instances from the %s cluster will be unregistered:"
             % clustername, cdslist)
     if force:
         Expect.expect(connection, "Forcibly remove these CDS instances", 60)
         Expect.enter(connection, "y")
     RHUIManager.quit(connection, timeout=30)
 def associate_repo_cds(connection, clustername, repolist):
     """
     associate a repository with a CDS cluster
     """
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "s")
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(
         connection,
         "The following repositories will be associated with the " + clustername + " cluster:",
         repolist,
         ["Red Hat Repositories", "Custom Repositories"],
     )
     RHUIManager.quit(connection)
 def delete_cds(connection, clustername, cdslist, force=False):
     """
     unregister (delete) a CDS instance from the RHUI
     """
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "d")
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select(connection, cdslist)
     RHUIManager.proceed_with_check(
         connection, "The following CDS instances from the %s cluster will be unregistered:" % clustername, cdslist
     )
     if force:
         Expect.expect(connection, "Forcibly remove these CDS instances", 60)
         Expect.enter(connection, "y")
     RHUIManager.quit(connection, timeout=30)
 def create_conf_rpm(connection, clustername, primary_cds, dirname, certpath, certkey, rpmname, rpmversion="", unprotected_repos=None):
     '''
     create a client configuration RPM from an entitlement certificate
     '''
     RHUIManager.screen(connection, "client")
     Expect.enter(connection, "c")
     Expect.expect(connection, "Full path to local directory.*:")
     Expect.enter(connection, dirname)
     Expect.expect(connection, "Name of the RPM:")
     Expect.enter(connection, rpmname)
     Expect.expect(connection, "Version of the configuration RPM.*:")
     Expect.enter(connection, rpmversion)
     Expect.expect(connection, "Full path to the entitlement certificate.*:")
     Expect.enter(connection, certpath)
     Expect.expect(connection, "Full path to the private key for the above entitlement certificate:")
     Expect.enter(connection, certkey)
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select_one(connection, primary_cds)
     if unprotected_repos:
         RHUIManager.select(connection, unprotected_repos)
     RHUIManager.quit(connection, "Successfully created client configuration RPM")
 def generate_ent_cert(connection, clustername, repolist, certname, dirname, validity_days="", cert_pw=None):
     '''
     generate an entitlement certificate
     '''
     RHUIManager.screen(connection, "client")
     Expect.enter(connection, "e")
     RHUIManager.select_one(connection, clustername)
     RHUIManager.select(connection, repolist)
     Expect.expect(connection, "Name of the certificate.*contained with it:")
     Expect.enter(connection, certname)
     Expect.expect(connection, "Local directory in which to save the generated certificate.*:")
     Expect.enter(connection, dirname)
     Expect.expect(connection, "Number of days the certificate should be valid.*:")
     Expect.enter(connection, validity_days)
     RHUIManager.proceed_with_check(connection, "Repositories to be included in the entitlement certificate:",
                                    repolist, ["Custom Entitlements", "Red Hat Repositories"])
     Expect.expect(connection, "Enter pass phrase for.*:")
     if cert_pw:
         Expect.enter(connection, cert_pw)
     else:
         Expect.enter(connection, Util.get_ca_password(connection))
     RHUIManager.quit(connection)