Last active
August 29, 2015 14:02
-
-
Save etoews/30df2444bcf3cace3c5d to your computer and use it in GitHub Desktop.
DevStack for TXLF 2014
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Login | |
ssh -i .ssh/id_rsa.rackspace [email protected] | |
# Install OpenStack Icehouse with DevStack | |
apt-get -y update | |
apt-get -y install curl git vim | |
git clone https://github.com/openstack-dev/devstack.git -b stable/icehouse devstack/ | |
devstack/tools/create-stack-user.sh | |
su stack | |
cd | |
git clone https://github.com/openstack-dev/devstack.git -b stable/icehouse devstack/ | |
cd devstack/ | |
wget https://gist.githubusercontent.com/everett-toews/3cbbf4c3d059848ac316/raw/6a18ded87190c87ac981e8682b783bb25aa9e844/local.conf | |
./stack.sh | |
# BSB and time for Q&A | |
more local.conf | |
ls | |
ls exercises/ | |
ls samples/ | |
ls tools/ | |
# Screen | |
screen -ls | |
sudo chmod a+rw /dev/pts/0 | |
screen -r stack | |
# Exit: Ctrl+a Ctrl+d | |
screen -r stack | |
# Jump to screen number: Ctrl+a <Number> | |
# Next screen: Ctrl+a Spacebar | |
# Scrollback: Ctrl+a Esc <PageUp/PageDn> | |
# Stop scrollback: Esc | |
# New screen: Ctrl+a c | |
# Exit: Ctrl+a Ctrl+d | |
# screen -X -S stack quit | |
# screen -c stack-screenrc | |
# Go to the dashboard http://my.ip.v4.address | |
# Username: demo | |
# Password: devstack | |
# Using curl & python | |
TOKEN=$(curl -s -X POST http://localhost:5000/v2.0/tokens -d '{"auth": {"passwordCredentials": {"username":"demo", "password":"devstack"}, "tenantName":"demo"}}' -H "Content-type: application/json" | python -c 'import json,sys; response=json.loads(sys.stdin.read()); print response["access"]["token"]["id"]') | |
echo $TOKEN | |
# Using curl & jq | |
sudo wget http://stedolan.github.io/jq/download/linux64/jq -O /usr/local/bin/jq | |
sudo chmod a+x /usr/local/bin/jq | |
TOKEN=$(curl -s -X POST http://localhost:5000/v2.0/tokens -d '{"auth": {"passwordCredentials": {"username":"demo", "password":"devstack"}, "tenantName":"demo"}}' -H "Content-type: application/json" | jq -r .access.token.id) | |
echo $TOKEN | |
# Using the command line interfaces | |
source /opt/stack/python-novaclient/tools/nova.bash_completion | |
source openrc demo demo | |
# Boot an instance | |
nova list | |
nova secgroup-list | |
nova secgroup-list-rules default | |
nova secgroup-add-rule default TCP 22 22 0.0.0.0/0 | |
nova secgroup-add-rule default ICMP -1 -1 0.0.0.0/0 | |
nova secgroup-list-rules default | |
nova keypair-list | |
nova keypair-add test > test.pem | |
ll test.pem | |
chmod 400 test.pem | |
ll test.pem | |
nova image-list | |
IMAGE_ID=$(nova image-list | egrep "cirros-.*-uec " | awk 'NR==1 {print $2}') | |
echo $IMAGE_ID | |
nova flavor-list | |
nova boot --flavor 1 --image $IMAGE_ID --key-name test --security-groups default test-vm | |
# use --no-public --no-service-net if you get ERROR (BadRequest): Network 0000, 1111 could not be found. (HTTP 400) | |
# use --poll to the boot command to Report the new server boot progress until it completes. | |
nova list | |
# For nova boot, all of the interactions that occur across services: | |
# http://ilearnstack.wordpress.com/2013/04/26/request-flow-for-provisioning-instance-in-openstack/ | |
ping 10.0.0.2 | |
ssh -i test.pem [email protected] | |
ls -al | |
uptime | |
uname -a | |
exit | |
# Database | |
mysql -uroot -pdevstack | |
show databases; | |
use nova; | |
show tables; | |
desc instances; | |
select id, display_name, vm_state from instances; | |
quit | |
# AMQP for RPC | |
sudo rabbitmqctl list_queues name | |
sudo rabbitmqctl list_exchanges name | |
# Go to the Rackspace Python SDK (pyrax) at http://developer.rackspace.com/#python | |
sudo pip install pyrax bpython | |
# To get the tenant id, paste it over <tenant-id> below | |
source openrc admin admin | |
keystone tenant-get demo | |
TENANT_ID=$(keystone tenant-get demo | grep id | awk '{print $4}') | |
echo $TENANT_ID | |
echo "[private] | |
identity_type = keystone | |
region = RegionOne | |
auth_endpoint = http://localhost:5000/v2.0/ | |
tenant_id = $TENANT_ID | |
debug = True" > ~/.pyrax.cfg | |
more ~/.pyrax.cfg | |
bpython | |
import pyrax | |
pyrax.set_credentials("demo", "devstack") | |
pyrax.regions | |
pyrax.cloudservers.list() | |
pyrax.cloudservers.list_images() | |
exit() | |
# Clean up | |
source openrc demo demo | |
nova list | |
nova list | grep test | awk '{print $2}' | xargs -n 1 nova delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment