コード例 #1
0
 def add_cds(connection, clustername, cdsname, hostname="", displayname=""):
     """
     register (add) a new CDS instance
     """
     RHUIManager.screen(connection, "cds")
     RHUIManagerCds._add_cds_part1(connection, cdsname, hostname, displayname)
     state = Expect.expect_list(
         connection,
         [
             (re.compile(".*Enter a CDS cluster name:.*", re.DOTALL), 1),
             (re.compile(".*Select a CDS cluster or enter a new one:.*", re.DOTALL), 2),
         ],
     )
     if state == 1:
         Expect.enter(connection, clustername)
     else:
         Expect.enter(connection, "b")
         Expect.expect(connection, "rhui \(cds\) =>")
         RHUIManagerCds._add_cds_part1(connection, cdsname, hostname, displayname)
         RHUIManagerCds._select_cluster(connection, clustername)
     # We need to compare the output before proceeding
     checklist = ["Hostname: " + cdsname]
     if hostname != "":
         checklist.append("Client Hostname: " + hostname)
     else:
         checklist.append("Client Hostname: " + cdsname)
     if displayname != "":
         checklist.append("Name: " + displayname)
     else:
         checklist.append("Name: " + cdsname)
     checklist.append("Cluster: " + clustername)
     RHUIManager.proceed_with_check(connection, "The following CDS instance will be registered:", checklist)
     RHUIManager.quit(connection, "Successfully registered")
コード例 #2
0
 def add_cds(connection, clustername, cdsname, hostname="", displayname=""):
     '''
     register (add) a new CDS instance
     '''
     RHUIManager.screen(connection, "cds")
     RHUIManagerCds._add_cds_part1(connection, cdsname, hostname, displayname)
     state = Expect.expect_list(connection, [(re.compile(".*Enter a CDS cluster name:.*", re.DOTALL), 1),
                                             (re.compile(".*Select a CDS cluster or enter a new one:.*", re.DOTALL), 2)])
     if state == 1:
         Expect.enter(connection, clustername)
     else:
         Expect.enter(connection, 'b')
         Expect.expect(connection, "rhui \(cds\) =>")
         RHUIManagerCds._add_cds_part1(connection, cdsname, hostname, displayname)
         RHUIManagerCds._select_cluster(connection, clustername)
     # We need to compare the output before proceeding
     checklist = ["Hostname: " + cdsname]
     if hostname != "":
         checklist.append("Client Hostname: " + hostname)
     else:
         checklist.append("Client Hostname: " + cdsname)
     if displayname != "":
         checklist.append("Name: " + displayname)
     else:
         checklist.append("Name: " + cdsname)
     checklist.append("Cluster: " + clustername)
     RHUIManager.proceed_with_check(connection, "The following CDS instance will be registered:", checklist)
     RHUIManager.quit(connection, "Successfully registered")
コード例 #3
0
 def delete_repo(connection, repolist):
     '''
     delete a repository from the RHUI
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "d")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(connection, "The following repositories will be deleted:", repolist, ["Red Hat Repositories", "Custom Repositories"])
     RHUIManager.quit(connection)
コード例 #4
0
 def sync_cds(connection, cdslist):
     '''
     sync an individual CDS immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sc")
     RHUIManager.select(connection, cdslist)
     RHUIManager.proceed_with_check(connection, "The following CDS instances will be scheduled for synchronization:", cdslist)
     RHUIManager.quit(connection)
コード例 #5
0
 def sync_cluster(connection, clusterlist):
     '''
     sync a CDS cluster immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sl")
     RHUIManager.select(connection, clusterlist)
     RHUIManager.proceed_with_check(connection, "The following CDS clusters will be scheduled for synchronization:", clusterlist)
     RHUIManager.quit(connection)
コード例 #6
0
 def delete_repo(connection, repolist):
     '''
     delete a repository from the RHUI
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "d")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(
         connection, "The following repositories will be deleted:",
         repolist, ["Red Hat Repositories", "Custom Repositories"])
     RHUIManager.quit(connection)
コード例 #7
0
 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)
コード例 #8
0
 def add_rh_repo_by_product(connection, productlist):
     '''
     add a new Red Hat content repository (By Product)
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "a")
     Expect.expect(connection, "Import Repositories:.*to abort:", 180)
     Expect.enter(connection, "2")
     RHUIManager.select(connection, productlist)
     RHUIManager.proceed_with_check(connection, "The following products will be deployed:", productlist)
     RHUIManager.quit(connection, "Content will not be downloaded", 45)
コード例 #9
0
 def sync_repo(connection, repolist):
     '''
     sync an individual repository immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sr")
     Expect.expect(connection, "Select one or more repositories.*for more commands:", 60)
     Expect.enter(connection, "l")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(connection, "The following repositories will be scheduled for synchronization:", repolist)
     RHUIManager.quit(connection)
コード例 #10
0
 def move_cds(connection, cdslist, clustername):
     '''
     move the CDSes to clustername
     '''
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "m")
     RHUIManager.select(connection, cdslist)
     RHUIManagerCds._select_cluster(connection, clustername)
     RHUIManager.proceed_with_check(connection,
             "The following Content Delivery Servers will be moved to the %s cluster:\r\n.*-+" % clustername,
             cdslist)
     RHUIManager.quit(connection, "successfully moved CDS")
コード例 #11
0
 def sync_cluster(connection, clusterlist):
     '''
     sync a CDS cluster immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sl")
     RHUIManager.select(connection, clusterlist)
     RHUIManager.proceed_with_check(
         connection,
         "The following CDS clusters will be scheduled for synchronization:",
         clusterlist)
     RHUIManager.quit(connection)
コード例 #12
0
 def sync_cds(connection, cdslist):
     '''
     sync an individual CDS immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sc")
     RHUIManager.select(connection, cdslist)
     RHUIManager.proceed_with_check(
         connection,
         "The following CDS instances will be scheduled for synchronization:",
         cdslist)
     RHUIManager.quit(connection)
コード例 #13
0
 def add_rh_repo_by_product(connection, productlist):
     '''
     add a new Red Hat content repository (By Product)
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "a")
     Expect.expect(connection, "Import Repositories:.*to abort:", 180)
     Expect.enter(connection, "2")
     RHUIManager.select(connection, productlist)
     RHUIManager.proceed_with_check(
         connection, "The following products will be deployed:",
         productlist)
     RHUIManager.quit(connection, "Content will not be downloaded", 45)
コード例 #14
0
 def upload_content_cert(connection, certpath):
     '''
     upload a new or updated Red Hat content certificate
     '''
     if certpath[:1] == '/':
         Expect.enter(connection, "mkdir -p `dirname " + certpath + "` && echo SUCCESS")
         Expect.expect(connection, "[^ ]SUCCESS")
     connection.sftp.put(certpath, certpath)
     RHUIManager.screen(connection, "entitlements")
     Expect.enter(connection, "u")
     Expect.expect(connection, "Full path to the new content certificate:")
     Expect.enter(connection, certpath)
     RHUIManager.proceed_with_check(connection, "The RHUI will be updated with the following certificate:", [certpath])
     RHUIManager.quit(connection, "Red Hat Entitlements.*Valid.*------------------")
コード例 #15
0
 def move_cds(connection, cdslist, clustername):
     """
     move the CDSes to clustername
     """
     RHUIManager.screen(connection, "cds")
     Expect.enter(connection, "m")
     RHUIManager.select(connection, cdslist)
     RHUIManagerCds._select_cluster(connection, clustername)
     RHUIManager.proceed_with_check(
         connection,
         "The following Content Delivery Servers will be moved to the %s cluster:\r\n.*-+" % clustername,
         cdslist,
     )
     RHUIManager.quit(connection, "successfully moved CDS")
コード例 #16
0
 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)
コード例 #17
0
 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)
コード例 #18
0
 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)
コード例 #19
0
 def sync_repo(connection, repolist):
     '''
     sync an individual repository immediately
     '''
     RHUIManager.screen(connection, "sync")
     Expect.enter(connection, "sr")
     Expect.expect(connection,
                   "Select one or more repositories.*for more commands:",
                   60)
     Expect.enter(connection, "l")
     RHUIManager.select(connection, repolist)
     RHUIManager.proceed_with_check(
         connection,
         "The following repositories will be scheduled for synchronization:",
         repolist)
     RHUIManager.quit(connection)
コード例 #20
0
 def add_rh_repo_by_repo(connection, repolist):
     '''
     add a new Red Hat content repository (By Repository)
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "a")
     Expect.expect(connection, "Import Repositories:.*to abort:", 180)
     Expect.enter(connection, "3")
     RHUIManager.select(connection, repolist)
     repocheck = list(repolist)
     for repo in repolist:
         #adding repo titles to check list
         repotitle = re.sub(" \\\\\([^\(]*\\\\\)$", "", repo)
         if not repotitle in repocheck:
             repocheck.append(repotitle)
     RHUIManager.proceed_with_check(connection, "The following product repositories will be deployed:", repocheck)
     RHUIManager.quit(connection, "Content will not be downloaded", 45)
コード例 #21
0
 def upload_content_cert(connection, certpath):
     '''
     upload a new or updated Red Hat content certificate
     '''
     if certpath[:1] == '/':
         Expect.enter(connection,
                      "mkdir -p `dirname " + certpath + "` && echo SUCCESS")
         Expect.expect(connection, "[^ ]SUCCESS")
     connection.sftp.put(certpath, certpath)
     RHUIManager.screen(connection, "entitlements")
     Expect.enter(connection, "u")
     Expect.expect(connection, "Full path to the new content certificate:")
     Expect.enter(connection, certpath)
     RHUIManager.proceed_with_check(
         connection,
         "The RHUI will be updated with the following certificate:",
         [certpath])
     RHUIManager.quit(connection,
                      "Red Hat Entitlements.*Valid.*------------------")
コード例 #22
0
 def add_rh_repo_by_repo(connection, repolist):
     '''
     add a new Red Hat content repository (By Repository)
     '''
     RHUIManager.screen(connection, "repo")
     Expect.enter(connection, "a")
     Expect.expect(connection, "Import Repositories:.*to abort:", 180)
     Expect.enter(connection, "3")
     RHUIManager.select(connection, repolist)
     repocheck = list(repolist)
     for repo in repolist:
         #adding repo titles to check list
         repotitle = re.sub(" \\\\\([^\(]*\\\\\)$", "", repo)
         if not repotitle in repocheck:
             repocheck.append(repotitle)
     RHUIManager.proceed_with_check(
         connection, "The following product repositories will be deployed:",
         repocheck)
     RHUIManager.quit(connection, "Content will not be downloaded", 45)
コード例 #23
0
 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)
コード例 #24
0
    def add_custom_repo(connection,
                        reponame,
                        displayname="",
                        path="",
                        checksum_alg="2",
                        entitlement="y",
                        entitlement_path="",
                        redhat_gpg="y",
                        custom_gpg=None):
        '''
        create a new custom repository
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "c")
        Expect.expect(connection, "Unique ID for the custom repository.*:")
        Expect.enter(connection, reponame)
        checklist = ["ID: " + reponame]
        Expect.expect(connection, "Display name for the custom repository.*:")
        Expect.enter(connection, displayname)
        if displayname != "":
            checklist.append("Name: " + displayname)
        else:
            checklist.append("Name: " + reponame)
        Expect.expect(connection,
                      "Path at which the repository will be served.*:")
        Expect.enter(connection, path)
        if path != "":
            path_real = path
        else:
            path_real = reponame
        checklist.append("Path: " + path_real)
        Expect.expect(connection, "Enter value.*:")
        Expect.enter(connection, checksum_alg)
        Expect.expect(
            connection,
            "Should the repository require an entitlement certificate to access\? \(y/n\)"
        )
        Expect.enter(connection, entitlement)
        if entitlement == "y":
            Expect.expect(
                connection,
                "Path that should be used when granting an entitlement for this repository.*:"
            )
            Expect.enter(connection, entitlement_path)
            if entitlement_path != "":
                checklist.append("Entitlement: " + entitlement_path)
            else:
                educated_guess, replace_count = re.subn(
                    "(i386|x86_64)", "$basearch", path_real)
                if replace_count > 1:
                    # bug 815975
                    educated_guess = path_real
                checklist.append("Entitlement: " + educated_guess)
        Expect.expect(connection, "packages are signed by a GPG key\? \(y/n\)")
        if redhat_gpg == "y" or custom_gpg:
            Expect.enter(connection, "y")
            checklist.append("GPG Check Yes")
            Expect.expect(
                connection,
                "Will the repository be used to host any Red Hat GPG signed content\? \(y/n\)"
            )
            Expect.enter(connection, redhat_gpg)
            if redhat_gpg == "y":
                checklist.append("Red Hat GPG Key: Yes")
            else:
                checklist.append("Red Hat GPG Key: No")
            Expect.expect(
                connection,
                "Will the repository be used to host any custom GPG signed content\? \(y/n\)"
            )
            if custom_gpg:
                Expect.enter(connection, "y")
                Expect.expect(
                    connection,
                    "Enter the absolute path to the public key of the GPG keypair:"
                )
                Expect.enter(connection, custom_gpg)
                Expect.expect(
                    connection,
                    "Would you like to enter another public key\? \(y/n\)")
                Expect.enter(connection, "n")
                checklist.append("Custom GPG Keys: '" + custom_gpg + "'")
            else:
                Expect.enter(connection, "n")
                checklist.append("Custom GPG Keys: \(None\)")
        else:
            Expect.enter(connection, "n")
            checklist.append("GPG Check No")
            checklist.append("Red Hat GPG Key: No")

        RHUIManager.proceed_with_check(
            connection, "The following repository will be created:", checklist)
        RHUIManager.quit(connection, "Successfully created repository")
コード例 #25
0
    def add_custom_repo(connection, reponame, displayname="", path="", checksum_alg="2", entitlement="y", entitlement_path="", redhat_gpg="y", custom_gpg=None):
        '''
        create a new custom repository
        '''
        RHUIManager.screen(connection, "repo")
        Expect.enter(connection, "c")
        Expect.expect(connection, "Unique ID for the custom repository.*:")
        Expect.enter(connection, reponame)
        checklist = ["ID: " + reponame]
        Expect.expect(connection, "Display name for the custom repository.*:")
        Expect.enter(connection, displayname)
        if displayname != "":
            checklist.append("Name: " + displayname)
        else:
            checklist.append("Name: " + reponame)
        Expect.expect(connection, "Path at which the repository will be served.*:")
        Expect.enter(connection, path)
        if path != "":
            path_real = path
        else:
            path_real = reponame
        checklist.append("Path: " + path_real)
        Expect.expect(connection, "Enter value.*:")
        Expect.enter(connection, checksum_alg)
        Expect.expect(connection, "Should the repository require an entitlement certificate to access\? \(y/n\)")
        Expect.enter(connection, entitlement)
        if entitlement == "y":
            Expect.expect(connection, "Path that should be used when granting an entitlement for this repository.*:")
            Expect.enter(connection, entitlement_path)
            if entitlement_path != "":
                checklist.append("Entitlement: " + entitlement_path)
            else:
                educated_guess, replace_count = re.subn("(i386|x86_64)", "$basearch", path_real)
                if replace_count > 1:
                    # bug 815975
                    educated_guess = path_real
                checklist.append("Entitlement: " + educated_guess)
        Expect.expect(connection, "packages are signed by a GPG key\? \(y/n\)")
        if redhat_gpg == "y" or custom_gpg:
            Expect.enter(connection, "y")
            checklist.append("GPG Check Yes")
            Expect.expect(connection, "Will the repository be used to host any Red Hat GPG signed content\? \(y/n\)")
            Expect.enter(connection, redhat_gpg)
            if redhat_gpg == "y":
                checklist.append("Red Hat GPG Key: Yes")
            else:
                checklist.append("Red Hat GPG Key: No")
            Expect.expect(connection, "Will the repository be used to host any custom GPG signed content\? \(y/n\)")
            if custom_gpg:
                Expect.enter(connection, "y")
                Expect.expect(connection, "Enter the absolute path to the public key of the GPG keypair:")
                Expect.enter(connection, custom_gpg)
                Expect.expect(connection, "Would you like to enter another public key\? \(y/n\)")
                Expect.enter(connection, "n")
                checklist.append("Custom GPG Keys: '" + custom_gpg + "'")
            else:
                Expect.enter(connection, "n")
                checklist.append("Custom GPG Keys: \(None\)")
        else:
            Expect.enter(connection, "n")
            checklist.append("GPG Check No")
            checklist.append("Red Hat GPG Key: No")

        RHUIManager.proceed_with_check(connection, "The following repository will be created:", checklist)
        RHUIManager.quit(connection, "Successfully created repository")