本文整理汇总了Python中appscale.tools.appscale.AppScale.up方法的典型用法代码示例。如果您正苦于以下问题:Python AppScale.up方法的具体用法?Python AppScale.up怎么用?Python AppScale.up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appscale.tools.appscale.AppScale
的用法示例。
在下文中一共展示了AppScale.up方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testUpWithEC2EnvironmentVariables
# 需要导入模块: from appscale.tools.appscale import AppScale [as 别名]
# 或者: from appscale.tools.appscale.AppScale import up [as 别名]
def testUpWithEC2EnvironmentVariables(self):
# if the user wants us to use their EC2 credentials when running AppScale,
# we should make sure they get set
appscale = AppScale()
# Mock out the actual file reading itself, and slip in a YAML-dumped
# file
contents = {
'infrastructure' : 'ec2',
'machine' : 'ami-ABCDEFG',
'instance_type' : 'm3.medium',
'keyname' : 'bookey',
'group' : 'boogroup',
'min_machines' : 1,
'max_machines' : 1,
'EC2_ACCESS_KEY' : 'access key',
'EC2_SECRET_KEY' : 'secret key',
'zone' : 'my-zone-1b'
}
yaml_dumped_contents = yaml.dump(contents)
self.addMockForAppScalefile(appscale, yaml_dumped_contents)
flexmock(os.path)
os.path.should_call('exists')
os.path.should_receive('exists').with_args(
'/boo/' + appscale.APPSCALEFILE).and_return(True)
# finally, pretend that our ec2 zone/image to use exist
fake_ec2 = flexmock(name="fake_ec2")
fake_ec2.should_receive('get_all_instances')
fake_ec2.should_receive('get_all_zones').with_args('my-zone-1b') \
.and_return('anything')
fake_ec2.should_receive('get_image').with_args('ami-ABCDEFG') \
.and_return()
flexmock(boto.ec2)
boto.ec2.should_receive('connect_to_region').with_args('my-zone-1',
aws_access_key_id='access key',
aws_secret_access_key='secret key').and_return(fake_ec2)
# finally, mock out the actual appscale-run-instances call
flexmock(AppScaleTools)
AppScaleTools.should_receive('run_instances')
appscale.up()
self.assertEquals('access key', os.environ['EC2_ACCESS_KEY'])
self.assertEquals('secret key', os.environ['EC2_SECRET_KEY'])
示例2: testUpWithCloudAppScalefile
# 需要导入模块: from appscale.tools.appscale import AppScale [as 别名]
# 或者: from appscale.tools.appscale.AppScale import up [as 别名]
def testUpWithCloudAppScalefile(self):
# calling 'appscale up' if there is an AppScalefile present
# should call appscale-run-instances with the given config
# params. here, we assume that the file is intended for use
# on EC2
appscale = AppScale()
# Mock out the actual file reading itself, and slip in a YAML-dumped
# file
contents = {
'infrastructure' : 'ec2',
'instance_type' : 'm3.medium',
'machine' : 'ami-ABCDEFG',
'keyname' : 'bookey',
'group' : 'boogroup',
'min_machines' : 1,
'max_machines' : 1,
'zone' : 'my-zone-1b'
}
yaml_dumped_contents = yaml.dump(contents)
self.addMockForAppScalefile(appscale, yaml_dumped_contents)
flexmock(os.path)
os.path.should_call('exists')
os.path.should_receive('exists').with_args(
'/boo/' + appscale.APPSCALEFILE).and_return(True)
# throw in some mocks for the argument parsing
for credential in EC2Agent.REQUIRED_CREDENTIALS:
os.environ[credential] = "baz"
# finally, pretend that our ec2 zone and image exists
fake_ec2 = flexmock(name="fake_ec2")
fake_ec2.should_receive('get_all_instances')
fake_ec2.should_receive('get_all_zones').with_args('my-zone-1b') \
.and_return('anything')
fake_ec2.should_receive('get_image').with_args('ami-ABCDEFG') \
.and_return()
flexmock(boto.ec2)
boto.ec2.should_receive('connect_to_region').with_args('my-zone-1',
aws_access_key_id='baz', aws_secret_access_key='baz').and_return(fake_ec2)
# finally, mock out the actual appscale-run-instances call
flexmock(AppScaleTools)
AppScaleTools.should_receive('run_instances')
appscale.up()
示例3: testUpWithClusterAppScalefile
# 需要导入模块: from appscale.tools.appscale import AppScale [as 别名]
# 或者: from appscale.tools.appscale.AppScale import up [as 别名]
def testUpWithClusterAppScalefile(self):
# calling 'appscale up' if there is an AppScalefile present
# should call appscale-run-instances with the given config
# params. here, we assume that the file is intended for use
# on a virtualized cluster
appscale = AppScale()
# Mock out the actual file reading itself, and slip in a YAML-dumped
# file
contents = {
'ips_layout': {'master': 'ip1', 'appengine': 'ip1',
'database': 'ip2', 'zookeeper': 'ip2'},
'keyname': 'boobazblarg',
'group': 'boobazblarg'
}
yaml_dumped_contents = yaml.dump(contents)
self.addMockForAppScalefile(appscale, yaml_dumped_contents)
flexmock(os.path)
os.path.should_call('exists')
os.path.should_receive('exists').with_args(
'/boo/' + appscale.APPSCALEFILE).and_return(True)
# for this test, let's say that we don't have an SSH key already
# set up for ip1 and ip2
# TODO(cgb): Add in tests where we have a key for ip1 but not ip2,
# and the case where we have a key but it doesn't work
key_path = os.path.expanduser('~/.appscale/boobazblarg.key')
os.path.should_receive('exists').with_args(key_path).and_return(False)
# finally, mock out the actual appscale tools calls. since we're running
# via a cluster, this means we call add-keypair to set up SSH keys, then
# run-instances to start appscale
flexmock(AppScaleTools)
AppScaleTools.should_receive('add_keypair')
AppScaleTools.should_receive('run_instances')
appscale.up()
示例4: main
# 需要导入模块: from appscale.tools.appscale import AppScale [as 别名]
# 或者: from appscale.tools.appscale.AppScale import up [as 别名]
def main():
""" Execute appscale script. """
appscale = AppScale()
if len(sys.argv) < 2:
print(AppScale.USAGE)
sys.exit(1)
command = sys.argv[1]
if command == "init":
if len(sys.argv) < 2:
cprint("Usage: appscale init [cloud | cluster]", 'red')
print("Specify 'cloud' for EC2, Eucalyptus, and Google Compute Engine " +
"deployments, and 'cluster' if running over a virtualized cluster.")
sys.exit(1)
try:
environment = sys.argv[2] if len(sys.argv) == 3 else None
appscale.init(environment)
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
cprint("AppScalefile successfully created! Be sure to " +
"customize it for your particular cloud or cluster.", 'green')
sys.exit(0)
elif command == "up":
try:
appscale.up()
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "services":
try:
services.main()
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "ssh":
if len(sys.argv) < 3:
index = None
else:
index = sys.argv[2]
try:
appscale.ssh(index)
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
except KeyboardInterrupt:
# don't print the stack trace on a Control-C
pass
elif command == "stats":
try:
appscale.stats(sys.argv[2:])
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "status":
try:
appscale.status(sys.argv[2:])
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "deploy":
try:
if len(sys.argv) < 3 or len(sys.argv) > 5:
cprint("Usage: appscale deploy [--project <id>] <path to your app>", 'red')
sys.exit(1)
if len(sys.argv) == 3:
appscale.deploy(sys.argv[2])
elif len(sys.argv) == 5:
if sys.argv[2] != '--project':
cprint("Usage: appscale deploy [--project <id>] <path to your app>", 'red')
sys.exit(1)
appscale.deploy(sys.argv[4], sys.argv[3])
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "create-user":
try:
if len(sys.argv) < 2 or len(sys.argv) > 3:
cprint("Usage: appscale create-user [--admin]", 'red')
sys.exit(1)
if len(sys.argv) == 3:
if sys.argv[2] == '--admin':
appscale.create_user(True)
else:
cprint("Error: Invalid argument to 'create-user' command. To create user as admin, "
"you should specify the option '--admin'", 'red')
cprint("Usage: appscale create-user --admin", 'red')
sys.exit(1)
elif len(sys.argv) == 2:
appscale.create_user()
except Exception as exception:
LocalState.generate_crash_log(exception, traceback.format_exc())
sys.exit(1)
elif command == "undeploy" or command == "remove":
#.........这里部分代码省略.........