Getting Started with the FUJITSU K5 API on a Windows Workstation

K5 is built using one of the most open, secure and scalable cloud platforms available in the market today –Openstack. Due to this it means every function you see displayed in the portal (and some you don’t) are all available to consume via a REST API. For more information on REST APIs take a look at https://en.wikipedia.org/wiki/Representational_state_transfer.

REST APIs require you to programmatically interact with them, meaning you need to write code or use a specific tool to enable you to send or receive information. The interaction with K5 REST APIs is performed using Linux command line/code, so requires a basic understanding and comfortable with using the Linux command line and understanding code syntax.

Cygwin
A tool such as Cygwin, can be used to provide a Linux command line on a MS Windows workstation. Cygwin (pronounced SIG-win) is a Unix-like environment and command-line interface for Microsoft Windows, providing native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment.

cURL
In order to submit the REST API commands from within the Cygwin environment, the Linux tool cURL is used. This is a command-line tool that lets you send HTTP requests and receive responses. For some practical examples using cURL visit http://www.thegeekstuff.com/2012/04/curl-examples/

JQ
JQ is a lightweight and flexible command-line JSON processor, that can be used to slice, filter, map and transform structured data passed to it. Its use is recommend and included in K5 API examples across the guides to filter, structure and present the result of submitted API commands in JSON format.

Installing Cygwin and cURL
1. Download the latest 64-bit version of Cygwin for Windows from https://cygwin.com/install.html and run ‘setup-x86_64.exe’ toc begin the install.

2. On the ‘Cygwin Setup’ screen click ‘Next’

3. On ‘Choose Installation Type’ screen select ‘Install from Internet’ and click ‘Next’

4. On ‘Choose Installation Directory’ screen, accept the default ‘Root Directory’ and ‘All Users (RECOMMENDED)’ and click ‘Next’

5. On ‘Select Local Package Directory’, accept the default and click ‘Next’

6. On ‘Select Connection Type’ screen, select ‘Use Internet Explorer Proxy Settings’ and click ‘Next’

7. On ‘Choose Download Site(s)’ screen, select anyone of the sites, click ‘Add’ and then ‘Next’

8. On ‘Select Package’ screen, enter ‘curl’ into the ‘Search’ box. NOTE: Do not click hit the ‘Return’ key as this progress the install wizard to the next screen.

9. In the results, expand ‘Net’ then click on ‘Default’ till it changes to ‘Install’.

10. Next, enter ‘make’ into the ‘Search’ box, in the results expand ‘Devel’, click on ‘Skip’ for the package ‘make: The GNU version of the “make” utility’, till it changes to a version number e.g. 4.1-1

11. Next, enter ‘gcc’ into the ‘Search’ box, click ‘Default’ next to ‘Devel’ to install all compiles (a GCC C compiler is required if you want to try just individual components)

(OPTIONAL) Other Linux components that you may be familiar with or likely to use can also be searched for and added in the same way. E.g. To install the editor VIM, enter ‘VIM’ into the ‘Search’ box, then in the results, expand ‘Editors’, click on ‘Default’ to change it to ‘Install’ and click ‘Next’

Once all packages are selected click ‘Next’.

12. For any “Resolving Dependencies” screens that may appear, click ‘Next’. The installation then begins and typically completes in around 10 to 15 minutes

13. Once installed, on the ‘Installation Status and Create Icons’ screen, accept defaults and click ‘Finish’ to complete the install

14. Cygwin can now be opened by double clicking on the ‘Cygwin64 Terminal’ desktop icon

To configure CURL to work in conjunction with a Proxy Server, perform the following:

1. Within Cygwin, using an editor of choice to create the file ‘.curlrc’ in the default ‘home’ folder, e.g. ‘vim .curlrc’
2. Edit this file to add the following information:

proxy-user=”:”    e.g. proxy-user=”smithd:Password!”

proxy=”:”             e.g. proxy=”proxy.acme.com:80″

E.g. Within VIM, press ‘i’ to enter ‘Edit Mode’ and then enter the following two lines, replacing and with your credentials (there is no need to enter a domain) :

Hit the ‘Esc’ key, then press the ‘Shift’ and “:” keys together. This should result in command line colon for VIM being displayed in the bottom left hand side of the screen, indicating ‘Edit Mode’ has been exited. Enter ‘wq’ to save and exit VIM

Installation of jq.exe into Cygwin

1. Download the latest ‘Source tarball for jq’ from https://stedolan.github.io/jq/download/
2. Open Cygwin to create home folders for the user
3. Copy the ‘jq-1.5.tar.gz’ file into c:\cygwin64\home\ to make it available within Cygwin
4. Within Cygwin, enter the following to un-compress the file : ‘tar -xvzf jq-1.5.tar.gz’
5. Change folder location to the uncompressed folder e.g. ‘cd /jq-1.5’
6. Next enter ‘./configure’ and wait for the command to complete (approx.. 5 minutes)
7. Then enter the commands ‘make’, followed by ‘make install’

jq.exe should now be installed

Configure K5 REST API  Working Environment

The final step is to build the API working environment. This is documented within the Fujitsu  K5 IaaS User Guide.

See below for an example Init.sh file template:

and below for example get_token.sh

Advertisements

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