Difference between revisions of "Piston: Command Line Cheatsheet Openstack"

From Define Wiki
Jump to navigation Jump to search
(Created page with "== Keystone (Identity Service) == # List all users keystone user-list # List identity service catalog keystone catalog # Discover keystone endpoints keystone discover #...")
(No difference)

Revision as of 22:51, 7 March 2015

Keystone (Identity Service)

  1. List all users
 keystone user-list
  1. List identity service catalog
 keystone catalog
  1. Discover keystone endpoints

keystone discover

  1. List all services in service catalog

keystone service-list

  1. Create new user

keystone user-create --name --tenant-id --pass --email --enabled

  1. Create new tenant

keystone tenant-create --name --description --enabled

Nova (Compute Service)

  1. List instances, notice status of instance

nova list

  1. List images

nova image-list

  1. List flavors

nova flavor-list

  1. Boot an instance using flavor and image names (if names are unique)

nova boot --image --flavor nova boot --image cirros-0.3.1-x86_64-uec --flavor m1.tiny MyFirstInstance

  1. Login to instance

ip netns sudo ip netns exec ssh <user@server or use a key> sudo ip netns exec qdhcp-6021a3b4-8587-4f9c-8064-0103885dfba2 ssh cirros@10.0.0.2

  1. if you are on devstack, password is “cubswin:)” without the quotes
  1. Show details of instance

nova show <name> nova show MyFirstInstance

  1. View console log of instance

nova console-log MyFirstInstance

  1. Pause, suspend, stop, rescue, resize, rebuild, reboot an instance
  2. Pause

nova pause <name> nova pause volumeTwoImage

  1. Unpause

nova unpause <name>

  1. Suspend

nova suspend <name>

  1. Unsuspend

nova resume <name>

  1. Stop

nova stop <name>

  1. Start

nova start <name>

  1. Rescue

nova rescue <name>

  1. Resize

nova resize <name> <flavor> nova resize my-pem-server m1.small nova resize-confirm server1

  1. Rebuild

nova rebuild <name> <image> nova rebuild newtinny cirros-qcow2

  1. Reboot

nova reboot <name> nova reboot newtinny

  1. Inject user data and files into an instance

nova boot --user-data ./userdata.txt MyUserdataInstance nova boot --user-data userdata.txt --image cirros-qcow2 --flavor m1.tiny MyUserdataInstance2

  1. to validate file is there, ssh into instance, go to /var/lib/cloud look for file
  1. Inject a keypair into an instance and access the instance with that keypair
  2. Create keypair

nova keypair-add test > test.pem chmod 600 test.pem

  1. Boot

nova boot --image cirros-0.3.0-x86_64 --flavor m1.small --key_name test my-first-server

  1. ssh into instance

sudo ip netns exec qdhcp-98f09f1e-64c4-4301-a897-5067ee6d544f ssh -i test.pem cirros@10.0.0.4

  1. Set metadata on an instance

nova meta volumeTwoImage set newmeta=’my meta data’

  1. Create an instance snapshot

nova image-create volumeTwoImage snapshotOfVolumeImage nova image-show snapshotOfVolumeImage

  1. Manage security groups
  2. Add rules to default security group allowing ping and ssh between #instances in the default security group

nova secgroup-add-group-rule default default icmp -1 -1 nova secgroup-add-group-rule default default tcp 22 22

Glance (Image Service)

  1. List images you can access

glance image-list

  1. Delete specified image

glance image-delete <image>

  1. Describe a specific image

glance image-show <image>

  1. update image

glance image-update <image>

  1. Manage images
  2. Kernel image

glance image-create --name “cirros-threepart-kernel” --disk-format aki --container-format aki --is-public True --file ~/images/cirros-0.3.1~pre4-x86_64-vmlinuz

  1. Ram image

glance image-create—name “cirros-threepart-ramdisk” --disk-format ari --container-format ari --is-public True --file ~/images/cirros-0.3.1~pre4-x86_64-initrd

  1. 3-part image

glance image-create—name “cirros-threepart” --disk-format ami --container-format ami --is-public True --property kernel_id=$KID—property ramdisk_id=$RID --file ~/images/cirros-0.3.1~pre4-x86_64-blank.img

  1. Register raw image

glance image-create --name “cirros-qcow2” --disk-format qcow2 --container-format bare --is-public True --file ~/images/cirros-0.3.1~pre4-x86_64-disk.img

Neutron (Networking Service)

  1. Create network

neutron net-create <name> neutron net-create my-network

  1. Create a subnet

neutron subnet-create <network name> <cidr> neutron subnet-create my-network 10.0.0.0/29

  1. List network and subnet

neutron net-list neutron subnet-list

  1. Examine details of network and subnet

neutron net-show <id or name of network> neutron subnet-show <id or name of subnet>

Cinder (Block Storage)

  1. Manage volumes and volume snapshots
  2. Create a new volume

cinder create <size in GB> --display-name cinder create 1 --display-name MyFirstVolume

  1. Boot an instance and attach to volume

nova boot—image cirros-qcow2 --flavor m1.tiny MyVolumeInstance

  1. List volumes, notice status of volume

cinder list

  1. Attach volume to instance after instance is active, and volume is available

nova volume-attach <instance-id> <volume-id> auto nova volume-attach MyVolumeInstance /dev/vdb auto

  1. Login into instance, list storage devices

sudo fdisk -l

  1. On the instance, make filesystem on volume

sudo mkfs.ext3 /dev/vdb

  1. Create a mountpoint

sudo mkdir /myspace

  1. Mount the volume at the mountpoint

sudo mount /dev/vdc /myspace

  1. Create a file on the volume

sudo touch /myspace/helloworld.txt sudo ls /myspace

  1. Unmount the volume

sudo umount /myspace

Swift (Object Store)

  1. Displays information for the account, container, or object

swift stat swift stat <account> swift stat <container> swift stat <object>

  1. List containers

swift list

  1. Create a container

swift post mycontainer

  1. Upload file to a container

swift upload <containder name> <file name> swift upload mycontainer myfile.txt

  1. List objects in container

swift list container

  1. Download object from container

swift download <containder name> <file name>

  1. Upload with chunks, for large file

swift upload -S <size> <containder name> <file name> swift upload -S 64 container largeFile