How to get CIDR or netmask after deploy instance.

Asked by Ellen Batbouta on 2016-11-01

When I deploy an instance, the IPs (both private and floating) are returned. However, my application needs more info. Is it possible to get the CIDR or netmask info as well? In the future, I can also envision needing additional info for ipv4 and ipv6.

A work around could be to parse the output of ip address show.

Question information

Language:
English Edit question
Status:
Solved
For:
Murano Edit question
Assignee:
No assignee Edit question
Solved by:
Stan Lagun
Solved:
2016-11-01
Last query:
2016-11-01
Last reply:
2016-11-01
Stan Lagun (slagun) said : #1

I see 2 possible ways to get this (or some of this) information:
1. There is a "joinedNetworks" property in the Instance class which can be used to get list of networks instance joined to ($instance.joinedNetworks.network). Each network object has a "describe" method which returns structure with info about network including CIDR. joinedNetworks was introduced in Newton. If you're on older version you will need to put more efforts into calculating list of networks for the instance (it can join Environment/Region networks or custom networks provided to the Instance explicitly)
2. Ask the VM. VMs get their network configuration through DHCP so you can write a shell script that will retrieve that information from VM

Thank you. I am using Mitaka. So I don't have the joinedNetworks property unfortunately. Here is what I have
done: I first check the property:

$.instance.networks.useEnvironmentNetwork

this is set to True

So then I get the default network info from the environment:

$defNet: $._environment.defaultNetworks.environment.describe()

The describe method returns a Network object, yes? How do I get
the CIDR from this?

The CIDR should be: $defNet.subnetCidr for a Neutron network.
In my case, there is no value for this field.

Best Stan Lagun (slagun) said : #3

Here is the structure that describe() returns: https://github.com/openstack/murano/blob/stable/mitaka/meta/io.murano/Classes/resources/NeutronNetwork.yaml#L178-L185

CIDR is under 'cidr' key so $._environment.defaultNetworks.environment.describe().cidr should work for you

Thank you. Just what I need.

Thanks Stan Lagun, that solved my question.