Ask Your Question
1

How to assign fixed ip Using Heat Template?

asked 2016-04-16 07:40:07 -0500

syko gravatar image

updated 2016-04-16 07:44:23 -0500

Hi,

I wrote the following HOT script to define a server with fixed ip on a private network.

server:
  type: OS::Nova::Server
  properties:
    image: { get_param: ImageID }
    flavor: { get_param: FlavorName }
    key_name: { get_param: KeyName }
    name: { get_param: ServerName }
    networks:
    - network: { get_param: NetID }
    - subnet: { get_param: Subnet }
    - fixed_ip: { get_param: FixedIP }

The private network & subnet is already created. When I run 'heat stack-create -f <the file=""> -P <params> servername', it gives me the following error message.

ERROR: One of the properties "network", "port", "uuid" or "subnet" should be set for the specified network of server "server".

I don't understand the error message,. I already gave network and subnet properties.

Can any one help me on this? Thanks for your help :D

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2016-04-20 06:51:07 -0500

dbaxps gravatar image

updated 2016-04-20 11:55:25 -0500

UPDATE 04/20/2016
Follow http://blog.oddbit.com/2013/12/06/an-...
Fist template ubuntu1510.yml

heat_template_version: 2016-04-08
parameters:
  key_name:
    type: string
    default: oskeymitaka0420
    description: oskeymitaka0420
  flavor:
    type: string
    description: Instance type for the instance to be created
    default: m1.small
    constraints:
      - allowed_values: [m1.nano, m1.tiny, m1.small, m1.large]
        description: Value must be one of 'm1.tiny', 'm1.small' or 'm1.large'
  image:
    type: string
    default: cirros
    description: ID or name of the image to use for the instance
  private_net_id:
    type: string
    description: Private network id
  private_subnet_id:
    type: string
    description: Private subnet id
  public_net_id:
    type: string
    description: Public network id
resources:
  instance1:
    type: OS::Nova::Server
    properties:
      name: instance1
      image: { get_param: image }
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      networks:
        - port: { get_resource: instance1_port0 }
  instance1_port0:
    type: OS::Neutron::Port
    properties:
      network_id: { get_param: private_net_id }
      security_groups:
        - default
      fixed_ips:
        - subnet_id: { get_param: private_subnet_id }
  instance1_public:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network_id: { get_param: public_net_id }
      port_id: { get_resource: instance1_port0 }
outputs:
  instance1_private_ip:
    description: IP address of instance1 in private network
    value: { get_attr: [ instance1, first_address ] }
  instance1_public_ip:
    description: Floating IP address of instance1 in public network
    value: { get_attr: [ instance1_public, floating_ip_address ] }

Second environment1.yml

parameters:
  image: Ubuntu1510Cloud-image
  flavor: m1.small
  private_net_id: 292a2f21-70af-48ef-b100-c0639a8ffb22
  private_subnet_id: d7aa6f0f-33ba-430d-a409-bd673bed7060
  public_net_id: 43daa7c3-4e04-4661-8e78-6634b06d63f3

Now run :-

[root@ip-192-169-142-54 ~(keystone_demo)]# heat stack-create -f ubuntu1510.yml   -e environment1.yml ubuntustack
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| id                                   | stack_name  | stack_status       | creation_time       | updated_time |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| 3d1f8d4b-5251-4ba6-921f-66c46e3e32e5 | mystack     | CREATE_COMPLETE    | 2016-04-20T15:58:29 | None         |
| 0c2b848c-4674-40f6-bf18-8f3ec84d796f | ubuntustack | CREATE_IN_PROGRESS | 2016-04-20T16:11:05 | None         |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
[root@ip-192-169-142-54 ~(keystone_demo)]# heat stack-list
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| id                                   | stack_name  | stack_status    | creation_time       | updated_time |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| 3d1f8d4b-5251-4ba6-921f-66c46e3e32e5 | mystack     | CREATE_COMPLETE | 2016-04-20T15:58:29 | None         |
| 0c2b848c-4674-40f6-bf18-8f3ec84d796f | ubuntustack | CREATE_COMPLETE | 2016-04-20T16:11:05 | None         |
+--------------------------------------+-------------+-----------------+---------------------+--

Verify IPs :-

 [root@ip-192-169-142-54 ~(keystone_demo)]#  heat stack-show  ubuntustack | grep output
| outputs               | [                                                                                                                             |
|                       |     "output_value": "50.0.0.12",                                                                                              |
|                       |     "output_key": "instance1_private_ip",                                                                                     |
|                       |     "output_value": "192.169.142.152",                                                                                        |
|                       |     "output_key": "instance1_public_ip",

END UPDATE

Attempt to follow http://blog.oddbit.com/2013/12/06/an-...
Create sections

parameters:
resources:
outputs:

in template.yml
Create environment.yml as a kind of :-

parameters:
  image: fedora-23-x86_64
  flavor: m1.small
  private_net_id: 99ab8ebf-ad2f-4a4b-9890-fee37cea4254
  private_subnet_id: ed8ad5f5-4c47-4204-9ca3-1b3bc4de286d
  public_net_id: 7e687cc3-8155-4ec2-bd11-ba741ecbf4f0

Then attempt :-

heat stack-create -f template.yml \
  -e environment.yml mystack
edit flag offensive delete link more

Comments

Thanks for your kind explanation. Where did you put the fixed IP address? The above Heat template instantiates a nova instance with both public and floating IPs assigned by DHCP server I guess, but not by a user (as a parameter)

syko gravatar imagesyko ( 2016-04-22 23:20:48 -0500 )edit

You wrote "The above Heat template instantiates a nova instance with both public and floating IPs assigned by DHCP server I guess" - the answer is "YES" via environment1.yml

dbaxps gravatar imagedbaxps ( 2016-04-23 10:32:43 -0500 )edit

private_net_id: 292a2f21-70af-48ef-b100-c0639a8ffb22
private_subnet_id: d7aa6f0f-33ba-430d-a409-bd673bed7060
public_net_id: 43daa7c3-4e04-4661-8e78-6634b06d63f3

dbaxps gravatar imagedbaxps ( 2016-04-23 10:33:00 -0500 )edit

I got it. Can I control, then, the exact fixed ip address assigned to 'instance1_port0'?

syko gravatar imagesyko ( 2016-04-24 22:07:44 -0500 )edit

Forget about heat, can you control DNSMASQ allocation IP for VM ?

dbaxps gravatar imagedbaxps ( 2016-04-25 02:06:25 -0500 )edit
1

answered 2016-12-08 10:25:04 -0500

Sergevs gravatar image

network section should looks as follow

networks:
    - { network: { get_param: NetID },  fixed_ip: { get_param: FixedIP } }
edit flag offensive delete link more
1

answered 2016-12-15 08:51:53 -0500

zaneb gravatar image

The problem here is your yaml formatting:

networks:
  - network: { get_param: NetID }
  - subnet: { get_param: Subnet }
  - fixed_ip: { get_param: FixedIP }

This creates three network interfaces, one that specifies only the network to connect to, one that specifies only the subnet, and one that specifies only the fixed IP. What you want is:

networks:
  - network: { get_param: NetID }
    subnet: { get_param: Subnet }
    fixed_ip: { get_param: FixedIP }

which creates a single network interface with all three pieces of data specified. (The difference is the leading -es, which indicate the start of a new entry in the networks list.)

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-04-16 07:40:07 -0500

Seen: 8,730 times

Last updated: Dec 15 '16