Add an Interface to an Existing Server on Fujitsu K5 or OpenStack

I had a query today from a customer looking for pointers on how to add another interface to an existing K5 or OpenStack instance. Hopefully if you’ve found this blog you too may find this useful. There’s a big assumption here that you have setup you environment for use with python 2.7X. However, because I’ve used the native API calls, it should be very easy to port this example to other scripting languages provided they support RESTFul calls.

Note: When running the script from a windows OS environment it may be necessary to replace the single quotes (‘) with double qoutes (“) around the parameters.

This procedure requires only two api calls –

  1. Get a project scoped token then
  2. Call the servers ‘add-interface’ api

As you can see from the above links, I’ve used the native OpenStack API calls from both the Keystone and Nova developers API documentation. Fujitsu K5 has also enhanced some of these APIs to provide richer functionality, those details are documented on the Fujitsu K5 site – http://www.fujitsu.com/uk/solutions/cloud/k5/guides/

Included is a basic wrapper around the API calls to facilitate simple command line use of the python script. The script takes 3 input parameters –

  • -p ‘project id’ – this is the id of the project where the server resides
  • -n ‘network id’ – this is the id of the network that the new interface is to be attached to
  • -s ‘server id’ – obviously enough this is where the id of the server that requires the additional interface resides

Also note that instead of hard coding the K5 contract details (e.g. username, password, etc) into the script I import them from another file called k5contractsettingsV7.py that YOU NEED TO CREATE before running the script. Place this file in the same directory as the script below.

Example of how to run the script – 

~/Dev/K5/CustomerAPIExamples$ ./ExampleServerAPIv1.py 
Script to demonstrate how to add an interface to an existing server.
Once complete it will be necessary to configure the interface  within the OS (a reboot may be required)
Usage: ./ExampleServerAPIv1.py -n 'network id' -s 'server id' -p 'project id'

~/Dev/K5/CustomerAPIExamples$ ./ExampleServerAPIv1.py -n 'b514ab88-0a32-4b84-a73f-d5eabfd9de72' -p '7015d1478a4c4bd7b970215d7b0260dd' -s '8a33075f-0894-4b9b-8b16-047457952f74'
8cee65fa81a44c4e9f5f111e6baea420
{u'interfaceAttachment': {u'port_state': u'DOWN', u'port_id': u'f645038a-2744-4c92-b0a6-2d350086a9ed', u'fixed_ips': [{u'subnet_id': u'1588ed79-3efe-44a7-be5b-075eb653f3bd', u'ip_address': u'192.168.1.6'}], u'net_id': u'b514ab88-0a32-4b84-a73f-d5eabfd9de72', u'mac_addr': u'fa:16:3e:5f:77:07'}}

 

Example python script to add a new network interface to an existing K5 or OpenStack instance.

Please also note that once this is complete you’ve only satisfied the infrastructure part of the process. It will still be necessary to configure the new interface within the relevant OS.

 

Happy Stacking!

#withk5youcan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s