python - trying to get info on boto docs -


i new python , looking boto quick list of sg. questions when @ boto docs listed below...how know attributes can use. example in sample output python below, create variable called inst....first used instance id, next used sg info....my question .... how know other attributes can get?? maybe instance type, ami-id etc.. reading doc below little bit confusing me new python...any help/pointers appreciated...

http://boto.readthedocs.org/en/latest/ref/ec2.html#module-boto.ec2.instance

>>> reservations = conn.get_all_instances() >>> in reservations:      inst = i.instances[0]      print inst  instance:i-c8990c39 instance:i-c7e45537 instance:i-698047c1 >>> >>> in reservations:      inst = i.instances[0].groups      print inst  [<boto.ec2.group.group object @ 0xf2c7d0>] [<boto.ec2.group.group object @ 0xf2c350>] [<boto.ec2.group.group object @ 0xf2c750>  <boto.ec2.group.group object @ 0x10992d0>] 

also, how come not sg instance id??

>>> in reservations:       inst = i.instances       print inst  [instance:i-c8990c39] [instance:i-c7e45537] [instance:i-698047c1]   >>> >>> in reservations:       sg = i.groups       print sg  [] [] [] >>> >>> 

check out python built-in function dir: https://docs.python.org/2/library/functions.html#dir

>>> reservations = conn.get_all_instances() >>> instance = reservations[0].instances[0] >>> dir(instance) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_in_monitoring_element', '_placement', '_previous_state', '_state', '_update', 'add_tag', 'ami_launch_index', 'architecture', 'block_device_mapping', 'client_token', 'confirm_product', 'connection', 'create_image', 'dns_name', 'ebs_optimized', 'endelement', 'eventsset', 'get_attribute', 'get_console_output', 'group_name', 'groups', 'hypervisor', 'id', 'image_id', 'instance_profile', 'instance_type', 'interfaces', 'ip_address', 'item', 'kernel', 'key_name', 'launch_time', 'modify_attribute', 'monitor', 'monitored', 'monitoring', 'monitoring_state', 'persistent', 'placement', 'placement_group', 'placement_tenancy', 'platform', 'previous_state', 'previous_state_code', 'private_dns_name', 'private_ip_address', 'product_codes', 'public_dns_name', 'ramdisk', 'reason', 'reboot', 'region', 'remove_tag', 'requester_id', 'reset_attribute', 'root_device_name', 'root_device_type', 'sourcedestcheck', 'spot_instance_request_id', 'start', 'startelement', 'state', 'state_code', 'state_reason', 'stop', 'subnet_id', 'tags', 'terminate', 'unmonitor', 'update', 'use_ip', 'virtualization_type', 'vpc_id'] 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -