小编max*_*alf的帖子

使用python boto检索安全组但设置vpc id

我正在尝试使用python boto和我运行以下示例(下面是这个的官方文档).我知道一个名为"Pub_HDP_SG"的SG存在,但当我尝试通过传入一个名为groupnames的参数来运行我的命令时,我得到以下错误.我知道这个SG在我的默认VPC中不存在,所以我如何将我的VPC设置为特定的VPC?

http://boto.readthedocs.org/en/latest/ref/ec2.html?highlight=get_all_security_groups#boto.ec2.connection.EC2Connection.get_all_security_groups

>>> import boto
>>> ec2 = boto.connect_ec2()
>>> sg = ec2.get_all_security_groups()
>>> print sg
[SecurityGroup:default, SecurityGroup:Pub_HDP_SG, SecurityGroup:RDP Rule - open everyone , SecurityGroup:us-east-open-all, SecurityGroup:wordpress-app-SG, SecurityGroup:default, SecurityGroup:AWS-AMI-SG, SecurityGroup:launch-wizard-2]
>>>
>>> sgn = "Pub_HDP_SG"
>>>
>>> sg = ec2.get_all_security_groups(groupnames=[sgn])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/boto/ec2/connection.py", line 2968, in get_all_security_groups
    [('item', SecurityGroup)], verb='POST')
  File "/usr/lib/python2.6/site-packages/boto/connection.py", line 1186, in get_list
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.EC2ResponseError: EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>InvalidGroup.NotFound</Code><Message>The security …
Run Code Online (Sandbox Code Playgroud)

python amazon-ec2 boto amazon-web-services aws-sdk

4
推荐指数
1
解决办法
2980
查看次数

错误...导入错误:没有名为 cassandra.cluster 的模块

我正在尝试遵循下面有关写入路径的视频,当我使用提供的示例学生文件时,我收到以下错误......我对 cassandra 非常陌生,并试图找出为什么练习文件不起作用。 ...我提供了我得到的错误(ImportError:没有名为 cassandra.cluster 的模块)以及 .sh 和 .py 文件...任何帮助都适用...

https://academy.datastax.com/courses/understanding-cassandra-write-path/understanding-data-files

    cass@cass:~/student-files/write-path/exercise-1$ ccm list
 *demo_1node
cass@cass:~/student-files/write-path/exercise-1$
cass@cass:~/student-files/write-path/exercise-1$ ccm status
Cluster: 'demo_1node'
---------------------
node1: UP
cass@cass:~/student-files/write-path/exercise-1$
cass@cass:~/student-files/write-path/exercise-1$ ./write_data.sh 300000
Traceback (most recent call last):
  File "./write_data.py", line 5, in <module>
    from cassandra.cluster import Cluster
ImportError: No module named cassandra.cluster
cass@cass:~/student-files/write-path/exercise-1$

cass@cass:~/student-files/write-path/exercise-1$ cat write_data.sh
#!/bin/bash

if [ $# -ne 1 ]; then
  echo "Usage: write_data.sh <number of keys>"
  exit 0
fi

if [ `ccm status | grep "node1: UP" | wc -l` …
Run Code Online (Sandbox Code Playgroud)

cassandra

2
推荐指数
1
解决办法
1万
查看次数

将私有 IP 分配给 Spot 实例

我想知道是否有办法在创建 Spot 实例时分配私有 IP。看起来默认情况下 AWS 控制台不会让您知道(在启动按需实例时可用)。但我想弄清楚是否可以为 Spot 实例分配私有 IP。

我的问题是,我有一个完成所有工作(应用程序安装等)的图像,当我使用图像触发现场实例并尝试登录网页时,它正在寻找该特定 IP 并作为现场实例不能给我想要的 IP 东西坏了......

任何帮助表示赞赏..

amazon-ec2

2
推荐指数
1
解决办法
1281
查看次数

从键/值对中获取值

对于一些python专业人士来说,这可能是一个非常微不足道的问题,但是我使用boto3来获取一些快照信息....我在下面做了一下并得到了...我的问题是我如何得到只是" VolumeId",我认为这是一个关键值输出我可以使用一些值rs.value得到它但我没有得到所需的输出...

>>> import boto3
>>> client = boto3.client('ec2')
>>> rs = client.describe_snapshots(SnapshotIds=['snap-656f5566'])
>>> print rs
{'ResponseMetadata': {'HTTPStatusCode': 200, 'RequestId': '6f99cc31-f586-48cf-b9bd-f5ca48a536fe'}, u'Snapshots': [{u'Description': 'Created by CreateImage(i-bbe81dc1) for ami-28ne0f44 from vol-72e14126', u'Encrypted': False, u'VolumeId': 'vol-41e14536', u'State': 'completed', u'VolumeSize': 30, u'Progress': '100%', u'StartTime': datetime.datetime(2012, 10, 7, 14, 33, 16, tzinfo=tzlocal()), u'SnapshotId': 'snap-658f5566', u'OwnerId': '0111233286342'}]}
>>>
>>>
>>> dir(rs)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', …
Run Code Online (Sandbox Code Playgroud)

python boto python-2.7 python-3.x boto3

0
推荐指数
1
解决办法
2602
查看次数