【发布时间】:2017-03-26 01:16:49
【问题描述】:
我正在学习面料。我想实现以下目标:ssh 进入我的 EC2 机器并 ls 主目录。
我从以下开始:
from boto import ec2
from fabric.colors import green as _green, yellow as _yellow
class EC2Conn:
def __init__(self):
print(_green("Started..."))
self.ec2conn = None
self.user = 'fabUser'
self.access_key = 'xxxx'
self.secret_key = 'xxxx'
def connect(self):
print(_green("Connecting..."))
ec2.connect_to_region("eu-west-1a")
self.ec2conn = ec2.connection.EC2Connection(self.access_key, self.secret_key)
print(self.get_instances())
def get_instances(self):
return self.ec2conn.get_all_instances()
def run_me():
a = EC2Conn()
a.connect()
但这给了我一个空白列表 [] 我确实有 1 个实例正在运行,所以这是不正确的。
【问题讨论】:
-
是否显示错误?
-
没有错误,它与详细信息连接,但显示并为空 []。当它应该有2个实例时。我设置了一个新用户并给他们正确的权限(完全管理员)
标签: python amazon-ec2 fabric