Difference between revisions of "Piston: Access using the CLI"

From Define Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
# Install packages:
 
# Install packages:
 
yum groupinstall 'Development tools'
 
yum groupinstall 'Development tools'
yum install http://repos.fedorapeople.org/repos/openstack/openstack-havana/rdo-release-havana-7.noarch.rpm
+
# EOL: yum install http://repos.fedorapeople.org/repos/openstack/openstack-havana/rdo-release-havana-7.noarch.rpm
 +
yum install https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.noarch.rpm
 
yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 
yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
 
yum install python-virtualenv
 
yum install python-virtualenv
Line 12: Line 13:
 
source openstack/bin/activate
 
source openstack/bin/activate
 
pip install python-cinderclient python-glanceclient python-keystoneclient python-neutronclient python-novaclient python-swiftclient cobalt-python-novaclient-ext
 
pip install python-cinderclient python-glanceclient python-keystoneclient python-neutronclient python-novaclient python-swiftclient cobalt-python-novaclient-ext
 +
pip install python-novaclient==2.15.0
 
###
 
###
 
# At this point you can source the RC file and use the commands below
 
# At this point you can source the RC file and use the commands below

Latest revision as of 08:28, 1 April 2015

Using Centos 6

# Install packages:
yum groupinstall 'Development tools'
# EOL: yum install http://repos.fedorapeople.org/repos/openstack/openstack-havana/rdo-release-havana-7.noarch.rpm
yum install https://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.noarch.rpm
yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install python-virtualenv
yum install openstack-utils
yum install python-devel openssl-devel python-pip git gcc libxslt-devel mysql-devel postgresql-devel libffi-devel libvirt-devel graphviz sqlite-devel
# Setup virtualenv 
virtualenv openstack
source openstack/bin/activate
pip install python-cinderclient python-glanceclient python-keystoneclient python-neutronclient python-novaclient python-swiftclient cobalt-python-novaclient-ext
pip install python-novaclient==2.15.0
###
# At this point you can source the RC file and use the commands below
###

Using Ubuntu 14.04

  • This was based on the ubuntu cloud 14.04 image within the piston openstack tutorail (fairly minimal setup)

Setup Virtual env

  • Setup virtualenv to setup an isolated python environment
sudo apt-get install python-dev
sudo apt-get install python-virtualenv
sudo apt-get install libffi-dev
sudo apt-get install libssl-dev

Setup Client Modules

  • Setup the virtual env and install all the openstack client modules
ubuntu@ubuntu-1404-dp:~$ virtualenv piston-openstack
New python executable in piston-openstack/bin/python
Installing setuptools, pip...done.
ubuntu@ubuntu-1404-dp:~$ source piston-openstack/bin/activate
(piston-openstack)ubuntu@ubuntu-1404-dp:~$ pip install python-cinderclient python-glanceclient \
                                                                                          python-keystoneclient python-neutronclient \
                                                                                          python-novaclient python-swiftclient cobalt-python-novaclient-ext

pip install netifaces

# Verify with: 
pip freeze

Download the RC file from the Piston Console

  • Do the following to download the RC file for your project:
  1. Log in to the dashboard as described in Logging in to the Dashboard.
  2. Select Admin > Project from the menu bar.
  3. Click Access & Security.
  4. Click Download OpenStack RC File.
  5. Move the downloaded file to your home directory.
  6. In a terminal window, change directory to the location where you moved the RC file.
  7. Execute the following command to source the RC file:
source projectname-openrc-region.sh
# or in my case
(piston-openstack)ubuntu@ubuntu-1404-dp:~$ source Daves\ Test\ Cloud-openrc.sh 
Please enter your OpenStack Password: 
(piston-openstack)ubuntu@ubuntu-1404-dp:~$


Using Glance

The Glance client allows a user to view, inspect and create virtual machine images within the cluster:

(piston-openstack)ubuntu@ubuntu-1404-dp:~$ glance image-list 
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+
| ID                                   | Name                      | Disk Format | Container Format | Size       | Status |
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+
| f3b414b2-863c-42f5-a832-22858486c91c | Centos 6 Generic Cloud    | qcow2       | bare             | 1151533056 | active |
| 483a03f1-93b5-4576-8b57-663ecbc31cd6 | Centos 7 Generic Cloud    | qcow2       | bare             | 989069312  | active |
| 1798f4aa-1871-4938-850b-b0029216c16a | Demo Image CirrOS 0.3.1 9 | qcow2       | bare             | 18350080   | active |
| 6ccb1b77-5988-4fa6-a637-45cb751a7504 | Ubuntu 14.04 LTS          | qcow2       | bare             | 256639488  | active |
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+

glance help will show you all of the options.

  • Steps to import an image:
ubuntu@ubuntu-1404-dp:~$ glance image-list
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+
| ID                                   | Name                      | Disk Format | Container Format | Size       | Status |
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+
| f3b414b2-863c-42f5-a832-22858486c91c | Centos 6 Generic Cloud    | qcow2       | bare             | 1151533056 | active |
| 483a03f1-93b5-4576-8b57-663ecbc31cd6 | Centos 7 Generic Cloud    | qcow2       | bare             | 989069312  | active |
| 1798f4aa-1871-4938-850b-b0029216c16a | Demo Image CirrOS 0.3.1 9 | qcow2       | bare             | 18350080   | active |
| 6ccb1b77-5988-4fa6-a637-45cb751a7504 | Ubuntu 14.04 LTS          | qcow2       | bare             | 256639488  | active |
+--------------------------------------+---------------------------+-------------+------------------+------------+--------+
ubuntu@ubuntu-1404-dp:~$ glance image-create --name "Windows Server 2012 R2" --disk-format qcow2 --container-format bare --is-public True --progress < windows_server_2012_r2_standard_eval_kvm_20140607.qcow2
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 0d35e3cd283df48a033675adc6f93975     |
| container_format | bare                                 |
| created_at       | 2015-03-02T22:36:26                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 3b7a0312-3799-460b-b66e-8c68cf701a39 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Windows Server 2012 R2               |
| owner            | f496354984ef401a8d4f959bb92c2f2d     |
| protected        | False                                |
| size             | 17182752768                          |
| status           | active                               |
| updated_at       | 2015-03-02T22:43:31                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+
ubuntu@ubuntu-1404-dp:~$ glance image-list
+--------------------------------------+---------------------------+-------------+------------------+-------------+--------+
| ID                                   | Name                      | Disk Format | Container Format | Size        | Status |
+--------------------------------------+---------------------------+-------------+------------------+-------------+--------+
| f3b414b2-863c-42f5-a832-22858486c91c | Centos 6 Generic Cloud    | qcow2       | bare             | 1151533056  | active |
| 483a03f1-93b5-4576-8b57-663ecbc31cd6 | Centos 7 Generic Cloud    | qcow2       | bare             | 989069312   | active |
| 1798f4aa-1871-4938-850b-b0029216c16a | Demo Image CirrOS 0.3.1 9 | qcow2       | bare             | 18350080    | active |
| 6ccb1b77-5988-4fa6-a637-45cb751a7504 | Ubuntu 14.04 LTS          | qcow2       | bare             | 256639488   | active |
| 3b7a0312-3799-460b-b66e-8c68cf701a39 | Windows Server 2012 R2    | qcow2       | bare             | 17182752768 | active |
+--------------------------------------+---------------------------+-------------+------------------+-------------+--------+

Using Nova

The Nova client gives access to all the functionality associated with virtual instances within the cluster:

# this wouldnt work in the virtualenv - exited out and install python-novaclient, re-sourced the rc file and worked ok: 
ubuntu@ubuntu-1404-dp:~$ nova list 
+--------------------------------------+--------------------------------------------------+--------+------------+-------------+---------------------------------+
| ID                                   | Name                                             | Status | Task State | Power State | Networks                        |
+--------------------------------------+--------------------------------------------------+--------+------------+-------------+---------------------------------+
| 02350e36-b358-4a8a-867e-8aeae2f5d68c | centos-6-dp                                      | ACTIVE | -          | Running     | private=172.16.3.6              |
| 7d9ca24a-ff40-457c-874a-d96c2d2f0c8e | centos-7-dp-7d9ca24a-ff40-457c-874a-d96c2d2f0c8e | ACTIVE | -          | Running     | private=172.16.3.3, 172.16.4.3  |
| eedc8512-6dca-4b1c-a129-cbe33f972599 | centos-7-dp-eedc8512-6dca-4b1c-a129-cbe33f972599 | ACTIVE | -          | Running     | private=172.16.3.2, 172.16.4.2  |
| 0926ed78-4a6a-4e7d-b06e-df774d07233b | cirros-dp                                        | ACTIVE | -          | Running     | private=172.16.3.10, 172.16.4.4 |
| 188fbc08-b413-4db2-9b96-f64233bbba56 | ubuntu-1404-dp                                   | ACTIVE | -          | Running     | private=172.16.3.8              |
+--------------------------------------+--------------------------------------------------+--------+------------+-------------+---------------------------------+

The nova command has a large number of subcommands and options, covering tasks as diverse as creating instances and attaching volumes to uploading SSH keys for injection and migrating instances between cloud nodes. nova help and nova help <subcommand> will help you to understand its capabilities.

Using Cinder

In order to create and work with block-storage volumes, you will use the Cinder client:

cinder list
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
|                  ID                  |   Status  |  Display Name  | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+
| 0f467714-28e8-423e-ba0d-2154c07c8cb4 | available | postgres_data  |  2   |     ceph    |  false   |             |
| 1a6e26db-db8a-4a38-be99-7e1a1f9aaa4c | available | General_backup |  5   |  ceph-slow  |  false   |             |
+--------------------------------------+-----------+----------------+------+-------------+----------+-------------+

As with the other commands, cinder help will explain its functionality in more detail.

Using Swift

The Swift client is for interacting with object storage:

$ swift list
images_for_download
static_assets
$ swift delete images_for_download
$ swift list
static_assets

Unless there are already containers and objects stored in your project, you probably won’t see any output from your swift list. swift help will help you get started with object storage from the command line.

Using Keystone

The Keystone client will be used almost exclusively by cloud administrators for managing users, projects and roles, and for viewing or manipulating endpoints and services:

keystone user-list
+----------------------------------+---------+---------+----------------------+
|                id                |   name  | enabled |        email         |
+----------------------------------+---------+---------+----------------------+
| a02d39f9a01a437da98ad3254bd94e9f |  admin  |   True  | changeme@example.com |
| 618b304aa7e04e6fa30ba2d6f345bcf8 |  cinder |   True  | changeme@example.com |
| 55a9b335eff1447eaa01e3df1739d94f |  glance |   True  | changeme@example.com |
| 2602c19224ca41449ea66d8371e5bbd6 | neutron |   True  | changeme@example.com |
| e0a968de5f014b05a35c6fa2ab2e2c7c |   nova  |   True  | changeme@example.com |
+----------------------------------+---------+---------+----------------------+