[openstack-dev] [tripleo][tripleo-heat-template] how to get interface name from network name in service profile

Ben Nemec openstack at nemebean.com
Tue Aug 1 18:23:02 UTC 2017



On 07/25/2017 09:53 PM, Zenghui Shi wrote:
> Hi,
> 
> Could anyone shed some light on how to get the physical interface name 
> (e.g eth0) from network name (e.g PublicNetwork, ExternalNetwork) in 
> tripleo-heat-template service profile ?
> 
> for example:
> 
> I want to add a service profile under puppet/services/time/ptp.pp where 
> it uses 'PtpInterface' as a parameter to get physical interface name 
> (please refer to below piece of code), but I'd like to expose a more 
> user friendly parameter like NetworkName(e.g. provision network, 
> external network etc) instead of 'PtpInterface' and retrieve the actual 
> physical interface name from the NetworkName where the physical 
> interface is connected to, is there any possible way to do this ?

I don't think there is.  In many cases the templates don't even know the 
name of the physical device on which the network will be running.  A 
simple example would be when a user uses the nicX abstraction to specify 
interfaces in their net-iso templates.  That doesn't get mapped to an 
actual interface name until os-net-config runs, and the results of that 
run are not available to the templates.

> 
> ####
> parameters:
> [...]
>    PtpInterface:      #  ---> change this parameter to PtpNetwork
>      default: eth0
>      description: PTP interfaces name.
>      type: string
> 
> resources:
>    RoleParametersValue
>      type: OS::Heat::Value
>      properties:
>        type: json
>        value:             # ---> add logic to get real interface name 
> from PtpNetwork
>          map_replace:
>            - map_replace:
>              - tripleo::profile::base::time::ptp::ptp4l_interface: 
> PtpInterface
>              - values: {get_param: [RoleParameters]}
>            - values:
>                PtpInterface: {get_param: PtpInterface}
> 
> outputs:
>    role_data:
>      description: Role ptp using commposable services.
>      value:
>        service_name: ptp
>        config_settings:
>          map_merge:
>            - get_attr: [RoleParametersValue, value]
> [...]
> ####
> 
> Thanks!
> zenghui
> 
> 
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> 



More information about the OpenStack-dev mailing list