Take your above code, and run it in the interactive interpreter.
Once you get here:
>>> server_list = nova.servers.list()
Extract the first server in the list:
>>> server = server_list[0]
And use python's dir
function to see what methods and attributes are available to you:
>>> dir(server)
['HUMAN_ID', 'NAME_ATTR', 'OS-DCF:diskConfig',
'OS-EXT-AZ:availability_zone', 'OS-EXT-STS:power_state',
'OS-EXT-STS:task_state', 'OS-EXT-STS:vm_state',
'OS-SRV-USG:launched_at', 'OS-SRV-USG:terminated_at', '__class__',
'__delattr__', '__dict__', '__doc__', '__eq__', '__format__',
'__getattr__', '__getattribute__', '__hash__', '__init__',
'__module__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__', '_add_details', '_info',
'_init_completion_cache', '_loaded', 'accessIPv4', 'accessIPv6',
'add_fixed_ip', 'add_floating_ip', 'add_security_group',
'addresses', 'backup', 'change_password', 'clear_password',
'config_drive', 'confirm_resize', 'create_image', 'created',
'delete', 'diagnostics', 'evacuate', 'flavor', 'force_delete',
'get', 'get_console_output', 'get_password', 'get_rdp_console',
'get_serial_console', 'get_spice_console', 'get_vnc_console',
'hostId', 'human_id', 'id', 'image', 'interface_attach',
'interface_detach', 'interface_list', 'is_loaded', 'key_name',
'links', 'list_security_group', 'live_migrate', 'lock', 'manager',
'metadata', 'migrate', 'name', 'networks',
'os-extended-volumes:volumes_attached', 'pause', 'progress',
'reboot', 'rebuild', 'remove_fixed_ip', 'remove_floating_ip',
'remove_security_group', 'rescue', 'reset_network', 'reset_state',
'resize', 'restore', 'resume', 'revert_resize', 'security_groups',
'set_loaded', 'shelve', 'shelve_offload', 'start', 'status',
'stop', 'suspend', 'tenant_id', 'to_dict', 'unlock', 'unpause',
'unrescue', 'unshelve', 'update', 'updated', 'user_id']
Well, let's see, there a flavor
attribute there:
>>> server.flavor
{u'id': u'2', u'links': [{u'href':
u'http://127.0.0.1:8774/95d9bbd9b446438a89a353d8adb60704/flavors/2',
u'rel': u'bookmark'}]}
We can use nova.flavors
just like you used nova.servers
to lookup
information about a server:
>>> flavor = nova.flavors.get(server.flavor['id'])
>>> flavor.disk
20
>>> flavor.vcpus
1
>>> flavor.name
u'm1.small'