本文整理汇总了Python中stitches.expect.Expect.expect_list方法的典型用法代码示例。如果您正苦于以下问题:Python Expect.expect_list方法的具体用法?Python Expect.expect_list怎么用?Python Expect.expect_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stitches.expect.Expect
的用法示例。
在下文中一共展示了Expect.expect_list方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_cds
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
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: initial_run
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
def initial_run(connection, crt="/etc/rhui/pem/ca.crt", key="/etc/rhui/pem/ca.key", cert_pw=None, days="", username="admin", password="admin"):
'''
Do rhui-manager initial run
'''
Expect.enter(connection, "rhui-manager")
state = Expect.expect_list(connection, [(re.compile(".*Full path to the new signing CA certificate:.*", re.DOTALL), 1),
(re.compile(".*RHUI Username:.*", re.DOTALL),2),
(re.compile(".*rhui \(home\) =>.*", re.DOTALL), 3)])
if state in [1, 2]:
if state == 1:
# Need to answer sone first-run questions
Expect.enter(connection, crt)
Expect.expect(connection, "Full path to the new signing CA certificate private key:")
Expect.enter(connection, key)
Expect.expect(connection, "regenerated using rhui-manager.*:")
Expect.enter(connection, days)
Expect.expect(connection, "Enter pass phrase for.*:")
if cert_pw:
Expect.enter(connection, cert_pw)
else:
Expect.enter(connection, Util.get_ca_password(connection))
Expect.expect(connection, "RHUI Username:")
Expect.enter(connection, username)
Expect.expect(connection, "RHUI Password:")
Expect.enter(connection, password)
Expect.expect(connection, "rhui \(home\) =>")
else:
# initial step was already performed by someone
pass
Expect.enter(connection, "q")
示例3: upload_content
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
def upload_content(connection, repolist, path):
'''
upload content to a custom repository
'''
# Temporarily quit rhui-manager and check whether "path" is a file or a directory.
# If it is a directory, get a list of *.rpm files in it.
Expect.enter(connection, 'q')
Expect.enter(connection, "stat -c %F " + path)
path_type = Expect.expect_list(connection, [(re.compile(".*regular file.*", re.DOTALL), 1), (re.compile(".*directory.*", re.DOTALL), 2)])
if path_type == 1:
content = [basename(path)]
elif path_type == 2:
Expect.enter(connection, "echo " + path + "/*.rpm")
output = Expect.match(connection, re.compile("(.*)", re.DOTALL))[0]
rpm_files = output.splitlines()[1]
content = []
for rpm_file in rpm_files.split():
content.append(basename(rpm_file))
else:
# This should not happen. Getting here means that "path" is neither a file nor a directory.
# Anyway, going on with no content, leaving it up to proceed_with_check() to handle this situation.
content = []
# Start rhui-manager again and continue.
RHUIManager.initial_run(connection)
RHUIManager.screen(connection, "repo")
Expect.enter(connection, "u")
RHUIManager.select(connection, repolist)
Expect.expect(connection, "will be uploaded:")
Expect.enter(connection, path)
RHUIManager.proceed_with_check(connection, "The following RPMs will be uploaded:", content)
Expect.expect(connection, "rhui \(" + "repo" + "\) =>")
示例4: add_hap
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
def add_hap(connection, hap=Hap(), update=False):
'''
Register (add) a new HAP instance
@param hap: rhuilib.hap.Hap instance
@param update: Bool; update the hap if it is already tracked or raise ExpectFailed
'''
RHUIManager.screen(connection, "loadbalancers")
Expect.enter(connection, "a")
Expect.expect(connection, ".*Hostname of the HAProxy Load-balancer instance to register:")
Expect.enter(connection, hap.host_name)
state = Expect.expect_list(connection, [ \
(re.compile(".*Username with SSH access to %s and sudo privileges:.*" % hap.host_name, re.DOTALL), 1),
(re.compile(".*A HAProxy Load-balancer instance with that hostname exists.*Continue\?\s+\(y/n\): ", re.DOTALL), 2)
])
if state == 2:
# hap of the same hostname is already being tracked
if not update:
# but we don't wish to update its config: raise
raise ExpectFailed("%s already tracked but update wasn't required" % hap.host_name)
else:
# we wish to update, send 'y' answer
Expect.enter(connection, "y")
# the question about user name comes now
Expect.expect(connection, "Username with SSH access to %s and sudo privileges:" % hap.host_name)
# if the execution reaches here, uesername question was already asked
Expect.enter(connection, hap.user_name)
Expect.expect(connection, "Absolute path to an SSH private key to log into %s as %s:" % (hap.host_name, hap.user_name))
Expect.enter(connection, hap.ssh_key_path)
state = Expect.expect_list(connection, [
(re.compile(".*Cannot find file, please enter a valid path.*", re.DOTALL), 1),
(PROCEED_PATTERN, 2)
])
if state == 1:
# don't know how to continue with invalid path: raise
Expect.enter(connection, CTRL_C)
Expect.enter(connection, "q")
raise InvalidSshKeyPath(hap.ssh_key_path)
# all OK, confirm
Expect.enter(connection, "y")
# some installation and configuration through Puppet happens here, let it take its time
Expect.expect(connection, "The HAProxy Load-balancer was successfully configured." + ".*rhui \(.*\) =>", 180)
示例5: add_cds
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
def add_cds(connection, cds=Cds(), update=False):
'''
Register (add) a new CDS instance
@param cds: rhuilib.cds.Cds instance
@param update: Bool; update the cds if it is already tracked or rise ExpectFailed
'''
RHUIManager.screen(connection, "cds")
Expect.enter(connection, "a")
Expect.expect(connection, "Hostname of the Content Delivery Server instance to register:")
Expect.enter(connection, cds.host_name)
state = Expect.expect_list(connection, [ \
(re.compile(".*Username with SSH access to %s and sudo privileges:.*" % cds.host_name, re.DOTALL), 1),
(re.compile(".*A Content Delivery Server instance with that hostname exists.*Continue\?\s+\(y/n\): ", re.DOTALL), 2)
])
if state == 2:
# cds of the same hostname is already being tracked
if not update:
# but we don't wish to update its config: raise
raise ExpectFailed("%s already tracked but update wasn't required" % cds.host_name)
else:
# we wish to update, send 'y' answer
Expect.enter(connection, "y")
# the question about user name comes now
Expect.expect(connection, "Username with SSH access to %s and sudo privileges:" % cds.host_name)
# if the execution reaches here, uesername question was already asked
Expect.enter(connection, cds.user_name)
Expect.expect(connection, "Absolute path to an SSH private key to log into %s as ec2-user:" % cds.host_name)
Expect.enter(connection, cds.ssh_key_path)
state = Expect.expect_list(connection, [
(re.compile(".*Cannot find file, please enter a valid path.*", re.DOTALL), 1),
(PROCEED_PATTERN, 2)
])
if state == 1:
# don't know how to continue with invalid path: raise
Expect.enter(connection, CTRL_C)
Expect.enter(connection, "q")
raise InvalidSshKeyPath(cds.ssh_key_path)
# all OK, confirm
Expect.enter(connection, "y")
# some installation and configuration through Puppet happens here, let it take its time
RHUIManager.quit(connection, "The Content Delivery Server was successfully configured.", timeout=180)
示例6: add_custom_repo
# 需要导入模块: from stitches.expect import Expect [as 别名]
# 或者: from stitches.expect.Expect import expect_list [as 别名]
def add_custom_repo(connection, reponame, displayname="", path="", checksum_alg="1", 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]
state = Expect.expect_list(connection, [(re.compile(".*Display name for the custom repository.*:", re.DOTALL), 1),\
(re.compile(".*Unique ID for the custom repository.*:", re.DOTALL), 2)])
if state == 1:
Expect.enter(connection, displayname)
if displayname != "":
checklist.append("Name: " + displayname)
else:
checklist.append("Name: " + reponame)
Expect.expect(connection, "Unique 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)
Expect.expect(connection, "Successfully created repository *")
Expect.enter(connection, "home")
else:
Expect.enter(connection, '\x03')
Expect.expect(connection, "rhui \(" + "repo" + "\) =>")