Instance resource should implement the SubnetId property

Bug #1163952 reported by Simon Pasquier
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Winson Chan
Grizzly
Fix Released
Medium
Robert Pothier

Bug Description

It should be possible to create an instance attached to an subnet which already exists.

Currently the creation of the following template fails with error "StackValidationFailed Property SubnetId not implemented yet":
{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "Sample template showing how to create an instance in an existing VPC/subnet. It assumes you have already created a VPC and a subnet. Derived from https://s3.amazonaws.com/cloudformation-templates-us-east-1/VPC_EC2_Instance_with_EIP_and_Security_Group.template",

  "Parameters" : {

    "KeyName" : {
      "Description" : "Name of and existing KeyPair to enable SSH access to the instance",
      "Type" : "String"
    },

    "SubnetId" : {
      "Type" : "String",
      "Description" : "SubnetId of an existing subnet in your Virtual Private Cloud (VPC)"
    },

    "InstanceType" : {
      "Description" : "EC2 instance type",
      "Type" : "String",
      "Default" : "m1.large",
      "AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
      "ConstraintDescription" : "must be a valid EC2 instance type."
    },

    "ImageId" : {
      "Type" : "String",
      "Description" : "Image name"
    }
  },

  "Resources" : {

    "Ec2Instance" : {
      "Type" : "AWS::EC2::Instance",
      "Properties" : {
        "InstanceType": { "Ref" : "InstanceType" },
        "ImageId" : { "Ref" : "ImageId" },
        "SubnetId" : { "Ref" : "SubnetId" },
        "KeyName" : { "Ref" : "KeyName" }
      }
    }
  },

  "Outputs" : {
    "InstanceId" : {
      "Value" : { "Ref" : "Ec2Instance" },
      "Description" : "Instance Id of newly created instance"
    }
  }
}

Revision history for this message
Simon Pasquier (simon-pasquier) wrote :

Associated discussion on the openstack-dev mailing list => http://lists.openstack.org/pipermail/openstack-dev/2013-April/007130.html

Steven Hardy (shardy)
Changed in heat:
status: New → Triaged
Steven Hardy (shardy)
Changed in heat:
milestone: none → havana-1
importance: Undecided → Medium
Changed in heat:
assignee: nobody → Winson Chan (winson-c-chan)
Revision history for this message
Winson Chan (winson-c-chan) wrote :

I want to go thru the code changes here to see if it's correct. So the goal here is to let user pass an existing subnet Id into the AWS Cloud Formation template as parameter and then boot the server in nova and configure the nic to appropriate quantum network. Are we assuming the Subnet in the AWS template == Network in quantum? The instance resource in heat already has the SubnetId in the properties_schema. So I'll be removing "Implemented": False from that property. Modify the handle_create and _build_nics in Instance to check validity of the network in nova and then add "net-id" key-value pair into the nic entries? If there's SubnetId specified at the Instance type but not at the NetworkInterface, is it assumed to use the SubnetId specified at the Instance?

Revision history for this message
Simon Pasquier (simon-pasquier) wrote :

SubnetId should map to a Quantum subnet id. More info about VPC/Quantum mappings here: https://wiki.openstack.org/wiki/Heat/VPC_Resources_Support

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

As Simon said, a SubnetId maps to a Quantum subnet id. So to implement this property should in theory require the following:
- call self.quantum().show_subnet with the provided SubnetId
- use the resulting associated network_id for that subnet as the 'net-id' value in the nic entries

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/28508

Changed in heat:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/28508
Committed: http://github.com/openstack/heat/commit/58d88f64d79ecc336a15e5898b1de1efd605f112
Submitter: Jenkins
Branch: master

commit 58d88f64d79ecc336a15e5898b1de1efd605f112
Author: Winson Chan <email address hidden>
Date: Tue May 7 23:13:49 2013 -0700

    Implement the SubnetId property in the Instance resource

    If the SubnetId parameter is given in the template, the handle_create method
    in the Instance resource verifies the subnet in quantum and configures the
    NetworkInterfaces for the subnet. If no NetworkInterface is specified, a port
    is created for the subnet and the nic is configured to use that port.

    Change-Id: I5a05cbe0798e6b181bf9dd3b547cda525e18480f
    Fixes: bug #1163952

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Steven Hardy (shardy)
tags: added: grizzly-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/grizzly)

Fix proposed to branch: stable/grizzly
Review: https://review.openstack.org/47566

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/grizzly)

Reviewed: https://review.openstack.org/47566
Committed: http://github.com/openstack/heat/commit/ed4a338979bcd6f88fb8f2abe34912fed64bd8b5
Submitter: Jenkins
Branch: stable/grizzly

commit ed4a338979bcd6f88fb8f2abe34912fed64bd8b5
Author: Robert Pothier <email address hidden>
Date: Fri Sep 20 09:20:46 2013 -0400

    Implement the SubnetId property in the Instance resource

    If the SubnetId parameter is given in the template, the handle_create method
    in the Instance resource verifies the subnet in quantum and configures the
    NetworkInterfaces for the subnet. If no NetworkInterface is specified, a port
    is created for the subnet and the nic is configured to use that port.

    Porting this fix into stable/grizzly

    (cherry picked from commit 58d88f64d79ecc336a15e5898b1de1efd605f112)
    Conflicts:
        heat/engine/resources/autoscaling.py
        heat/tests/test_instance.py
        heat/tests/test_instance_network.py

    Change-Id: I92da0800565392004c4f75ad186f67b638df2df1
    Fixes: bug #1163952

Thierry Carrez (ttx)
Changed in heat:
milestone: havana-1 → 2013.2
Alan Pevec (apevec)
tags: removed: grizzly-backport-potential
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.