As the function get_server_private_ip says, it will look for an IP on the 'private' network for a server.
Why restrict the key_name to be 'private'? As I know the key_name here should be the network name. Why should I always name the network to be 'private' when using it to create a server?
https://github.com/openstack-infra/shade/blob/master/shade/meta.py#L148
This is an example, the server details got by shade is
Munch({'vm_state': u'active', u'OS-EXT-STS:task_state': None, 'addresses': Munch({u'vping_ssh-net_f40e24f4-882f-4e53-9547-632f255955c4': [Munch({u'OS-EXT-IPS-MAC:mac_addr': u'fa:16:3e:54:8a:12', u'version': 4, u'addr': u'192.168.120.9', u'OS-EXT-IPS:type': u'fixed'})]}), 'terminated_at': None, 'image': Munch({u'id': u'd02f098c-ea87-4707-8688-7bfc59aa50f8'}), u'OS-EXT-AZ:availability_zone': u'nova', u'OS-EXT-STS:vm_state': u'active', u'OS-SRV-USG:launched_at': u'2018-07-31T09:24:29.000000', 'flavor': Munch({u'id': u'ea07d79c-c124-40cc-becd-69c3e2e6b173'}), 'az': u'nova', 'id': u'f6cd1a3a-203c-4317-8ee3-0fb434a0cc2d', 'security_groups': [Munch({u'name': u'vping_ssh-sg_f40e24f4-882f-4e53-9547-632f255955c4'})], u'os-extended-volumes:volumes_attached': [], 'user_id': u'd38d7b2ed5f242439c5191746d79d52a', 'disk_config': u'MANUAL', u'OS-DCF:diskConfig': u'MANUAL', 'networks': {}, 'accessIPv4': u'', 'accessIPv6': u'', 'location': Munch({'project': Munch({'domain_id': None, 'id': u'78ad0a1767674d4f966e603c0f9f784a', 'name': 'vping_ssh-project_f40e24f4-882f-4e53-9547-632f255955c4', 'domain_name': 'Default'}), 'zone': u'nova', 'region_name': 'RegionOne', 'cloud': 'envvars'}), 'power_state': 1, 'public_v4': '', 'progress': 0, u'OS-EXT-STS:power_state': 1, 'interface_ip': '', 'launched_at': u'2018-07-31T09:24:29.000000', 'metadata': Munch({}), 'status': u'ACTIVE', 'updated': u'2018-07-31T09:24:30Z', 'hostId': u'b53ee29f02eb8e408733e1c2416994216c9bd93e11ad2d1af03160ad', u'OS-SRV-USG:terminated_at': None, 'key_name': u'vping_ssh-kp_f40e24f4-882f-4e53-9547-632f255955c4', 'public_v6': '', 'private_v4': None, 'cloud': 'envvars', 'host_id': u'b53ee29f02eb8e408733e1c2416994216c9bd93e11ad2d1af03160ad', 'task_state': None, 'properties': Munch({u'OS-EXT-STS:task_state': None, u'OS-SRV-USG:terminated_at': None, u'OS-DCF:diskConfig': u'MANUAL', u'os-extended-volumes:volumes_attached': [], u'OS-EXT-STS:vm_state': u'active', u'OS-SRV-USG:launched_at': u'2018-07-31T09:24:29.000000', u'OS-EXT-STS:power_state': 1, u'OS-EXT-AZ:availability_zone': u'nova'}), 'project_id': u'78ad0a1767674d4f966e603c0f9f784a', 'name': u'vping_ssh-vm_f40e24f4-882f-4e53-9547-632f255955c4', 'adminPass': None, 'tenant_id': u'78ad0a1767674d4f966e603c0f9f784a', 'region': 'RegionOne', 'created': u'2018-07-31T09:24:18Z', 'has_config_drive': False, 'volumes': [], 'config_drive': u''})
To my knowledge, it should get the ip '192.168.120.9' as this server's private ip. However, the only key of the 'addresses' is 'vping_ssh-net_f40e24f4-882f-4e53-9547-632f255955c4' which is the network name rather than 'private'. So it will return a empty dict.
I don't understand why it need to restrict the key to be 'private' which is just the name of the network.