通常、ページ付けは、APIを要求するクライアントによって実行されます。botoでこれを行うには、システムを切断する必要があります。たとえば、get_all_instances defを使用して、boto経由でAWSを呼び出すとします。それらを何らかの方法で保存してから、表示されているサーバーと表示されていないサーバーを追跡する必要があります。私の知る限り、botoには、ほとんどの開発者がMySQLから使用しているLIMIT機能がありません。個人的には、すべてのインスタンスをスキャンして、次のようにmongoに格納します。
for r in conn.get_all_instances(): # loop through all reservations
groups = [g.name for g in r.groups] # get a list of groups for this reservation
for x in r.instances: # loop through all instances with-in reservation
groups = ','.join(groups) # join the groups into a comma separated list
name = x.tags.get('Name',''); # get instance name from the 'Name' tag
new_record = { "tagname":name, "ip_address":x.private_ip_address,
"external_ip_nat":x.ip_address, "type":x.instance_type,
"state":x.state, "base_image":x.image_id, "placement":x.placement,
"public_ec2_dns":x.public_dns_name,
"launch_time":x.launch_time, "parent": ObjectId(account['_id'])}
new_record['groups'] = groups
systems_coll.update({'_id':x.id},{"$set":new_record},upsert=True)
error = db.error()
if error != None:
print "err:%s:" % str(error)
これらをtry/catchブロックでラップすることもできます。君による。ボトからそれらを取り出したら、カットアップ作業を行うのは簡単なはずです。
-ジェス