wiki:GENIExperimenter/Tutorials/GENI-SAVI/DesignSetup

Version 23 (modified by chmeyer@bbn.com, 9 years ago) (diff)

--

Get to Know GENI and SAVI

Hello GENI index Hello GENI index Hello GENI index

STEPS FOR SETTING UP


0. Get a SAVI account and an Omni bundle

(These steps were covered in the pre-work but if not yet completed they must be before step 1)

  • Getting a SAVI account:
  • As a GENI user, scroll down on the GENI portal homepage until you see "Tools". There, hit the SAVI button. Proceed through the remaining prompts until you get an email with you SAVI username and password.
  • Getting an Omni bundle:

  • In the GENI portal, click "Profile" and then "Configure Omni" in the set of tabs on the profile page. There, click the "Download your omni data" button.

1.Use the SAVI Client and the Federation Tool to Create a GENI Slice OMNI Bundle

  • Use scp to transfer the Omni Bundle you downloaded in pre-work to the Downloads folder on client1.savitestbed.ca. From the folder in which you have the Omni bundle, run
$ scp omni.bundle <savi-username>@client1.savitestbed.ca:Downloads

Windows users can use winscp

  • Using your SAVI credentials, log in to client1.savitestbed.ca. Any ssh tool can be used for this, including Putty and cygwin ssh on Windows, and the builtin terminal tools on any Unix- or Linux-based

system.

$ ssh <savi-username>@client1.savitestbed.ca
  • Once you're logged in, run
    $ omni-configure
    

to configure Omni. Omni-configure should have placed your ssh keys (id_rsa and id_rsa.pub) in your .ssh folder on client1.savitestbed.ca. Check to make sure that the keys are there.

  • Now download and unpack the GENI-SAVI Federation Tool
$ wget http://web.uvic.ca/~sushilb/federation/tutorial.tar
$  tar xvf tutorial.tar

2. Create a slice on GENI and Add Some VMs to it

We will now create a slice on GENI. Use your GENI username as the slice name. In the tutorial directory,

$ ./tutorial.sh createslice geni <your_geni_username>

Now add a VM at the Utah Downtown Data Center GENI rack

$ ./tutorial.sh createvm geni slice-name https://boss.utahddc.geniracks.net:12369/protogeni/xmlrpc/am/2.0 Ubuntu-14-04

This will take about a minute. It will then come back with a response of the form

  Result Summary: Got Reserved resources RSpec from utahddc-geniracks-net. Reservation at utahddc-ig in slice rizpan expires at 2015-05-25 22:59:40 (UTC).
"hostname="<name>.utahddc.geniracks.net"

 To connect to the created VM please use to the given hostname="<name>.utahddc.geniracks.net"

The machine will now be in a booting state. It will take about 5-10 minutes before you can log in. We'll use the time productively and create a SAVI VM while we wait.


3. Create VMs on SAVI at Toronto and Victoria

The general form of the command to create a VM on SAVI is

$ ./tutorial.sh createvm savi <tenant_name> <location> <os_image_name> <machine_name> <access_key> <vm-size> <vm-name>

we have chosen values for all parameters; each group will be given a specific site at the tutorial. The vm-name should be your geni-username, followed by the sitename. E.g., for rickmcg, the name at Toronto will be rickmcg-toronto

$ ./tutorial.sh createvm savi <tenant_name> toronto Ubuntu-14-04-64 small id_rsa <geni_username>-toronto

We now have VMs at, Utah and at one SAVI site. Check the status of your resources on both GENI and SAVI

$ ./tutorial.sh listinstance geni
$ ./tutorial.sh listinstance savi

Notice that access to the SAVI machines are by IP address

4. Learn some basic concepts of Ansible

Ansible (http://docs.ansible.com) is a free, open-source, intuitive IT automation tool that is well-suited to the tasks in this tutorial. Ansible commands can be run from the command line or put in a YAML file called a playbook. We will be creating an Ansible playbook to run the parameterized HTTP query described earlier.

Two basic concepts in Ansible are inventories and modules. An inventory is a list of hosts to be managed by Ansible, organized into groups. When you run Ansible commands, either from the command-line or in a playbook, you specify the host group that the command should operate on. In this way Ansible commands can operate on many hosts in parallel. Take a look at the Ansible inventory in your ansible-hosts file. This is basically the equivalent of the ssh-config except it's specialized for Ansible.

A task in Ansible consists of a module and some arguments for the module. A module provides a declarative abstraction on top of standard shell commands. So for example, in the shell on an Ubuntu machine you might install package “foo” like this:

$ sudo apt-get update
$ sudo apt-get install foo

An equivalent Ansible task in a playbook would look like:

- apt: name=foo state=latest update_cache=yes 

Or the same Ansible task could be invoked directly on the command line like this:

$ ansible remote-machine -m apt -a "name=foo state=latest update_cache=yes"

The task uses the apt module, and tells Ansible: “Make sure the latest version of package foo is installed”. There are many other modules which are well-documented at http://docs.ansible.com.

Here are a few Ansible tasks to run, to get some experience with the command-line interface.

(a) Create an Ansible Hosts file

An Ansible hosts file is of the form

  [group_name]
       server1_spec
       server2_spec

where group_name is a name for a group of nodes, and a server spec contains login information for a node. An example of a server specification is

    savi_toronto ansible_ssh_host=142.150.208.146  ansible_ssh_port=22 ansible_ssh_user=rickmcg_geni ansible_ssh_private_key=~/.ssh/id_rsa

An example ansible hosts file for a slice is:

[nodes]
    pc1.geni.it.cornell.edu ansible_ssh_port=34874 ansible_ssh_user=jbourne ansible_ssh_key=~/.ssh/geni_key_portal
    savi-toronto 142.150.208.149 ansible_ssh_user=ubuntu ansible_ssh_key=~/.ssh/savi-tutorial

Create an Ansible Hosts file for your slice. You can use either an IP address or an FQDN as an ssh host; if the ansible_ssh_host parameter is omitted it defaults to the name of the machine

(b) The ping module

The ping module simply tries to do a SSH login to a node and reports success or failure. Run the following command on your controller:

$ ansible nodes -i ansible-hosts -m ping

If you don’t see success everywhere then there is something wrong with your setup. Ask one of the tutorial leaders for help.

(c) The shell module

The shell module lets you run arbitrary SSH commands in parallel across a set of hosts. It’s useful for poking around, or if there is no Ansible module with the functionality you need. Try it out:

$ ansible nodes -i ansible-hosts -m shell -a "hostname"

You can replace hostname above with any other Linux command.

(d) The setup module

The setup module gathers a bunch of information about each node and saves it in variables that you can reference in your Ansible playbooks. This will be really useful to do the tutorial! Try it out on a node to see what it collects (replace <your-vm> with your hostname):

$ ansible <yourvm>.utahddc.geniracks.net -i ansible-hosts -m setup

(e) A simple playbook

Next, we will look at a simple Ansible playbook. An Ansible playbook is a YAML file containing a list of Ansible tasks. Copy the playbook below into a file called test.yaml:

---
- hosts: nodes
  remote_user: root
  tasks:
  - name: An example of a debug statement
    debug: var=ansible_hostname

Run the playbook as:

$ ansible-playbook -i ansible-hosts test.yaml

The setup module is run automatically at the beginning of a playbook to populate variables for each node. The above playbook will dump the value of each node’s ansible_hostname variable. To run the playbook on a single node, replace nodes with the name of one of your slice nodes (e.g., slice338.pcvm3-7.instageni.nps.edu).


5. Create and run an Ansible playbook to install the software you'll need

Now you should have enough knowledge about Ansible to write a playbook to install the software you'll need on all the nodes. Below is a skeleton Ansible playbook that you can use. You will need to fill in the bits marked # INSERT ARGUMENTS HERE to perform the actions described in the name lines. If you get stuck at any point, you can take a look at this solution.

---
- hosts: nodes
  remote_user: root
  tasks:
  - name: Update apt cache
    apt: # INSERT ARGUMENTS HERE

  - name: Install dnsutils (for dig)
    apt: # INSERT ARGUMENTS HERE

  - name: Install geoip-bin (for geoiplookup)
    apt: # INSERT ARGUMENTS HERE

Run this playbook on your Ansible control machine against all the nodes in your slice.

Pro Tip: use the -f argument to ansible-playbook to speed things up -- it lets you control the number of nodes to operate on in parallel, and the default is 5. Specifying -f 20 will run the playbook's tasks against all your slicelet nodes in parallel.

Next: Run Experiment

Attachments (2)

Download all attachments as: .zip