Jump to: navigation, search

Difference between revisions of "Obsolete:Add-options-network-create-os-apis"

m (Text replace - "__NOTOC__" to "")
Line 1: Line 1:
__NOTOC__
+
 
 
* '''Launchpad Entry''': add-options-network-create-os-apis
 
* '''Launchpad Entry''': add-options-network-create-os-apis
 
* '''Created''': 2011-07-11
 
* '''Created''': 2011-07-11

Revision as of 23:26, 17 February 2013

  • Launchpad Entry: add-options-network-create-os-apis
  • Created: 2011-07-11
  • Contributors: Tushar Patil, Koji Iida, Ishii Hisaharu

Summary

Our goal is to add optional parameter to the Create server API to achieve following objectives:-

1) Specify number and order of networks to the create server API.

In the current implementation every instance you launch for a project having 3 networks assigned to it will always have 3 vnics for every instance. In this case it is not possible to have one instance with 2 vnics ,another with 1 vnic and so on. This is not flexible enough and the network resources are not used effectively. So there should be some provision given to the users to specify the networks from the project at the time of server creation process.

2) Support fixed IP address reservation. When you launch a server, you can specify the fixed IP address you want to be assigned to the vnic from a particular network.

User stories

Our customer needs the flexibility to create instances based on the specified networks from the available pool of networks assigned to the project. This will help them to utilize the network resources effectively in the given project. Also user needs a way to assign reserved fixed IP address to the instance.

Design

This feature will be supported only to the OS API for all network models.

1) nova-manage changes Expose network id in the network list command. This will help admin users to identify the network id associated with the network which can passed at the time of server creation process.

2) Create Server Request:-

Modify existing Create server request to send additional information 'networks'.

Example 1 Server Create Request: XML

<?xml version="1.0" encoding="UTF-8"?>

<server xmlns="http://docs.nttpflab.com/servers/api/v1.0"
	name="new-server-test" imageId="1" flavorId="1">
  <metadata>
    <meta key="My Server Name">Apache1</meta>
  </metadata>
  <personality>
    <file path="/etc/banner.txt">
        ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp
    </file>
  </personality>
  <networks>
      <network id="1" fixed_ip="10.0.0.3">
      <network id="2" fixed_ip="10.0.1.3">
  </networks>
</server>

Example 2 Server Create Request: JSON

{
    "server" : {
        "name" : "new-server-test",
        "imageId" : 1,
        "flavorId" : 1,
        "metadata" : {
            "My Server Name" : "Apache1" 
        },
        "personality" : [
            {
                "path" : "/etc/banner.txt",
                "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp" 
            } 
        ]
        "networks" : [
	     { "id": "1", "fixed_ip": "10.0.0.3"},
	     { "id": "2", "fixed_ip": "10.0.1.3"},
        ]
    }
}

3) Create Server Response:

No changes are required in the Create Server Response.

4) Validations:

- Check if duplicate networks are not provided

- Check if the networks are assigned to the project

- Check if the fixed IP address is valid

- Check if the fixed IP address specified belongs to the network and also it is not one of the reserved ip addresses of that network.

- Check if the fixed IP address is not assigned to any instance

If you don't specify networks, then by default all the networks assigned to the project will be used as it is in the current implementation. If you don't specify fixed_ip address for a particular network, then in this case the free available fixed_IP address will be picked up from that network as it is in the current implementation else whichever fixed ip address is provided will be used.

Implementation

1) Reuse existing module, create_instance_helper.py->create_instance

Parse the parameters from the body, validate them and send these newly added parameters to the create_method.

3) nova/compute/api.py

class: API

change the signature of the create method to

def create(self, context, instance_type,
               image_href, kernel_id=None, ramdisk_id=None,
               min_count=1, max_count=1,
               display_name='', display_description='',
               key_name=None, key_data=None, security_group='default',
               availability_zone=None, user_data=None, metadata={},
               injected_files=None,
               admin_password=None,
               requested_networks=None)

Add new method (_check_requested_networks) which will be called from inside the _check_create_parameters method to ensure correct networks are passed to the compute service.

4) nova/compute/manager.py

class : ComputeManager

Method : run_instances

Inside this method, do following

a) Get the requested networks from the kwargs requested_networks = kwargs.get('requested_networks', None)

b) Pass this requested_networks to the network_api->allocated_for_instance method. network_info = self.network_api.allocate_for_instance(context,

                                                     instance,
                                                     vpn=is_vpn,
                                                     requested_networks=requested_networks)

5) nova/network->manager.py

class : NetworkManager

Method : allocated_for_instance method

a) Make appropriate changes in the _get_networks_for_instance method to filter out the requested_networks if it's not None else return all networks assigned to the project. b) Modify allocate_fixed_ip method to add one more parameter address. if this address is None, then the free available fixed IP address will be assigned to the instance else the specified address will be used.

UI Changes

No changes required.

Migration

No changes required in the database and there is no need to migrate any kind of data.

Test/Demo Plan

Unit/smoke tests will be provided as code is developed

Unresolved issues

None.