本文整理汇总了Python中appscale.tools.appscale_tools.AppScaleTools.relocate_app方法的典型用法代码示例。如果您正苦于以下问题:Python AppScaleTools.relocate_app方法的具体用法?Python AppScaleTools.relocate_app怎么用?Python AppScaleTools.relocate_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appscale.tools.appscale_tools.AppScaleTools
的用法示例。
在下文中一共展示了AppScaleTools.relocate_app方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all_ok
# 需要导入模块: from appscale.tools.appscale_tools import AppScaleTools [as 别名]
# 或者: from appscale.tools.appscale_tools.AppScaleTools import relocate_app [as 别名]
def test_all_ok(self):
# If the user wants to relocate their app to port X, and nothing else
# runs on that port, this should succeed.
# Assume that the AppController is running, so is our app, and that other
# apps are not running on port 80.
fake_appcontroller = flexmock(name='fake_appcontroller')
fake_appcontroller.should_receive('get_app_info_map').with_args(
'the secret').and_return(json.dumps({
self.appid : {
'nginx' : 8080
},
'a-different-app' : {
'nginx' : 81
}
}))
fake_appcontroller.should_receive('relocate_app').with_args(self.appid, 80,
443, 'the secret').and_return("OK")
flexmock(SOAPpy)
SOAPpy.should_receive('SOAPProxy').with_args('https://public1:17443') \
.and_return(fake_appcontroller)
rh = flexmock(RemoteHelper)
rh.should_receive('sleep_until_port_is_open').and_return()
argv = [
'--keyname', self.keyname,
'--appname', self.appid,
'--http_port', '80',
'--https_port', '443'
]
options = ParseArgs(argv, self.function).args
AppScaleTools.relocate_app(options)
示例2: relocate
# 需要导入模块: from appscale.tools.appscale_tools import AppScaleTools [as 别名]
# 或者: from appscale.tools.appscale_tools.AppScaleTools import relocate_app [as 别名]
def relocate(self, appid, http_port, https_port):
""" 'relocate' provides a nicer experience for users than the
appscale-terminate-instances command, by using the configuration options
present in the AppScalefile found in the current working directory.
Args:
appid: A str indicating the name of the application to relocate.
http_port: An int that indicates what port should serve HTTP traffic for
this application.
https_port: An int that indicates what port should serve HTTPS traffic for
this application.
Raises:
AppScalefileException: If there is no AppScalefile in the current working
directory.
"""
contents = self.read_appscalefile()
contents_as_yaml = yaml.safe_load(contents)
# Construct the appscale-relocate-app command from argv and the contents of
# the AppScalefile.
command = []
if 'keyname' in contents_as_yaml:
command.append("--keyname")
command.append(contents_as_yaml["keyname"])
command.append("--appname")
command.append(appid)
command.append("--http_port")
command.append(str(http_port))
command.append("--https_port")
command.append(str(https_port))
# and exec it
options = ParseArgs(command, "appscale-relocate-app").args
AppScaleTools.relocate_app(options)