yet.org

HP Cloud cheatsheet

HP recently launched their public cloud computing services based on OpenStack. In this article we will details some tips & tricks to efficiently use their services with Opscode Chef.

Install Chef and Knife Plugin for HP Cloud

$ gem install chef
$ gem install knife-hp

gather information regarding your HP Cloud Account: Access Key ID, Secret Key, Tenant ID and Availability Zone (az1, az2 or az3)

$ vi chef-repo/.chef/knife.rb

#add the following lines                              
knife[:hp_account_id] = "Your HP Cloud Access Key ID"
knife[:hp_secret_key] = "Your HP Cloud Secret Key"
knife[:hp_tenant_id]  = "Your HP Cloud Tenant ID"
knife[:hp_auth_uri]   = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens"
knife[:hp_avl_zone]   = "az1" #do not pass any Availability Zone if working with az3 or it won't work        

$ knife hp image list -VV [to test credentials]

Install HP Fog, HP CLI & Setup account

$ curl -sL https://docs.hpcloud.com/file/hpfog-0.0.17.gem >hpfog-0.0.17.gem
$ gem install hpfog-0.0.17.gem
$ curl -sL https://docs.hpcloud.com/file/hpcloud-1.2.0.gem >hpcloud-1.2.0.gem
$ gem install hpcloud-1.2.0.gem
$ hpcloud account:setup

Create SSH key pairs

$ ssh-keygen # generate .ssh/id_rsa  and .ssh/id_rsa.pub [back them up !!!]

Add keypair to HP Cloud

paste public key to HP Cloud

Create a server using web UI

  1. Create a new server from the management interface, select the key uploaded above and default security group (which allow ping & SSH)
  2. Connect to your instance using ssh -i private-key ubuntu@public_ip

Create a server using Knife

$ knife hp server create --flavor 100 --image 120 --ssh-key sebbraun --ssh-user ubuntu  #make sure your .chef/vmw-validatorpem is up to date with Chef Server
$ knife hp server create -f 100 -I 120 -S hpkeypair -i ~/.ssh/hpkeypair.pem -Z az2 -x ubuntu -r 'role[webserver]'

Flavor list

$ knife hp flavor list

100 standard.xsmall 1 1024 MB 30 GB

Image List

$ knife hp image list

120 Ubuntu Precise 12.04 LTS Server 64-bit 20120424

Server list

$ knife hp server list

316459 hp15–185–229–18 15.185.229.64 10.2.0.223 100 120 sebbraun active

Server pause

  1. create an Image of your running instance : Compute > Images > Create
  2. terminate running instance: Servers > click on instance ID > Terminate
  3. create a new server from previous image

Server delete

$ knife hp server delete 65646 -P -y --node-name hp15-185-229-18 # -P to also delete Node from Chef Server, node-name necessary if ID different from it.

Security Groups

#LIST
$ hpcloud securitygroups

#DETAILS
$ hpcloud securitygroups:rules GROUPID

#ADD
$ hpcloud securitygroups:rules:add GROUPID tcp -p 80..80

Addresses

#LIST
$ hpcloud addresses

#DISASSOCIATE
$ hpcloud addresses:disassociate <ip_or_id>

#ASSOCIATE
$ hpcloud addresses:associate <ip_or_id>