PI

This is the command line interface to CloudPi Cloud Application Platform

_Copyright 2010-2012, Samsung.

  1. For Users

1.1 Prerequisite: Installing Ruby and RubyGems

Currently support Ruby version v1.8.7 and v1.9.2
Installing Ruby and RubyGems on Windows and Linux computers(If you have already installed Ruby and RubyGems, then you can skip to Installing pi Steps):
Windows:

Download and install Ruby Installer for Windows from www.rubyinstaller.org. The installer already includes RubyGems. Be sure you use the Ruby-enabled command prompt window when you later install and use pi. You access this command prompt from the Windows Start menu (All Programs > Ruby <version> > Start Command Prompt with Ruby). Linux: Install the full Ruby package and RubyGems: $ apt-get install ruby-full rubygems $ ruby -v $ gem -v 1.2 Installing pi

$ gem install pi
$ pi version

1.3 Quick Start

To get full help for pi command line, run:
$ pi help
To get info for pi command line, run:
$ pi info
To , run:
$ pi 
  1. For Developers

2.1 Dependency

"json_pure", "~> 1.5.1"
"highline", "~> 1.6.1"
"rest-client", ">= 1.6.1", "< 1.7.0"
"terminal-table", "~> 1.4.2"
"interact", "~> 0.4.0"

2.2 Creating Your Own Gem

If you want to use your own pi command line based on currently pi command line, you can rewrite your own code, then create a gem. You can refer to RubyGems Manuals (http://docs.rubygems.org/read/chapter/5). Here are simple steps:
a.create a gem specification(for example, you can define my_pi.gemspec)
b.$ gem build my_pi.gemspec, after that my_pi.gem is created.
c.$ gem push my_pi-1.0.0.gem, that will instantly deploy your gem to the rubygems.org servers, and other users will be able to install it using gem install.
d.$ gem install my_pi.gem
  1. Help

    "Usage: pi [options] command [<args>] [command_options]\n" +
    "Try 'pi help [command]' or 'pi help options' for more information."
    
Currently available pi commands are:

User
   [url]                                  
  logout                                       Logs current user out of the system
  info                                         List system information
  user                                         Display user information
  targets                                      List available targets infomation
  github [name]                                Bind to the github 
  runtimes                                     Display the supported runtimes of the system
  frameworks                                   Display the supported frameworks of the system
  version                                      Display version information
  help [command]                               Get general help or help on a specific command
  help options                                 Get help on available options

Project
  projects                                     List created projects 
  create-project [projectname]                 Create a new project                
  delete-project [projectname]                 Delete the project             
  project-events [projectname]                 List the event info for the project
  project-tags [projectname]                   List the tags for the project
  project-commits [projectname]                List the commit log for the project
  project-apps [projectname]                   List the applications for the project
  upload [projectname]                         Upload the war package for java project

Application
  apps                                         List deployed applications for the project
  create-app [appname]                         Create a new application
  delete-app [appid]                           Delete the application
  start-app [appid]                            Start the application
  stop-app [appid]                             Stop the application
  restart-app [appid]                          Restart the application
  scale-app [appid]                            Scale the application instances up or down
  update-app [appid]                           Update the application
  status [appname]                             Display resource usage for the application
  app-env [appid]                              Display the environments for the application
  create-env [appid]                           Create the environment for the application
  delete-env [appid]                           Delete the environment for the application
  app-log [appid]                              List the logs for the application

Service
  app-service [appname]                        Display the bind services for the application
  bind-service [appname]                       Bind a service to an application
  unbind-service [appname]                     Unbind a service to an application

DNS
  app-dns [appname]                            Display the mapped urls for the application
  map-dns [appname]                            Map the url for the application
  unmap-dns [appname]                          Unmap the url for the application
  1. Example

ubuntu@admin:~$ pi login Attempting login to ‘api.staging.samsungcloud.org’? [Yn]: User: wangjing Password: ******* Successfully logged into [api.staging.samsungcloud.org]

ubuntu@admin:~$ pi version pi 0.1.22

ubuntu@admin:~$ pi user

UserName: wangjing DomainName: bst RoleName: user State: Active Github Account Name: ruanzhimin Github Account Email: [email protected]

ubuntu@admin:~$ pi targets

------------————————————+ | Name | URL | ------------————————————+ | ap-ne-test | ap-ne-test.samsungcloud.org | ------------————————————+

ubuntu@admin:~$ pi runtimes

-------- | Name | -------- | java | | ruby18 | --------

ubuntu@admin:~$ pi frameworks

---------- | Name | ---------- | lift | | spring | | grails | | java_web | | rails3 | | sinatra | ----------

ubuntu@admin:~$ pi github Please input your name: ruanzhimin Please input your email: [email protected] Please input your password: **************** ok

ubuntu@admin:~$ pi help

Usage: pi [options] command [<args>] [command_options] Try ‘pi help [command]’ or ‘pi help options’ for more information.

Currently available pi commands are:

User
   [url]                                  
  logout                                       Logs current user out of the system
  info                                         List system information
  user                                         Display user information
  targets                                      List available targets infomation
  github [name]                                Bind to the github 
  runtimes                                     Display the supported runtimes of the system
  frameworks                                   Display the supported frameworks of the system
  version                                      Display version information
  help [command]                               Get general help or help on a specific command
  help options                                 Get help on available options

Project
  projects                                     List created projects 
  create-project [projectname]                 Create a new project                
  delete-project [projectname]                 Delete the project             
  project-events [projectname]                 List the event info for the project
  project-tags [projectname]                   List the tags for the project
  project-commits [projectname]                List the commit log for the project
  project-apps [projectname]                   List the applications for the project
  upload [projectname]                         Upload the war package for java project

Application
  apps                                         List deployed applications for the project
  create-app [appname]                         Create a new application
  delete-app [appid]                           Delete the application
  start-app [appid]                            Start the application
  stop-app [appid]                             Stop the application
  restart-app [appid]                          Restart the application
  scale-app [appid]                            Scale the application instances up or down
  update-app [appid]                           Update the application
  status [appname]                             Display resource usage for the application
  app-env [appid]                              Display the environments for the application
  create-env [appid]                           Create the environment for the application
  delete-env [appid]                           Delete the environment for the application
  app-log [appid]                              List the logs for the application

Service
  app-service [appname]                        Display the bind services for the application
  bind-service [appname]                       Bind a service to an application
  unbind-service [appname]                     Unbind a service to an application

DNS
  app-dns [appname]                            Display the mapped urls for the application
  map-dns [appname]                            Map the url for the application
  unmap-dns [appname]                          Unmap the url for the application

ubuntu@admin:~$ pi help options

Available options:

-t [TKEY]
    --trace [TKEY]
-q, --quiet
    --verbose
    --json
-v, --version
-h, --help
    --options

ubuntu@admin:~$ pi projects

-----------------———-----------———--------------------------------------------------------------------——------------- | Name | Runtime | Framework | Git Type | GitUrl | ID | Description | -----------------———-----------———--------------------------------------------------------------------——------------- | javatestgithub | java | spring | github | [email protected]/ruanzhimin/javatestgithub.git | 1931 | test | | railstestgithub | ruby18 | rails3 | github | [email protected]/ruanzhimin/railstestgithub.git | 1929 | test | | railswj | ruby18 | rails3 | cloudpi | [email protected]/wangjing/railswj.git | 2028 | test | -----------------———-----------———--------------------------------------------------------------------——-------------

ubuntu@admin:~$ pi create-project Project Name: javawj

Runtime============
  1. java

  2. ruby18

Select Runtime: 1 Selected Runtime: java

Frameworks============
  1. lift

  2. spring

  3. grails

  4. java_web

Select Framework: 2 Selected Framework: spring Please enter in the description: test

Repository Types============
  1. cloudpi

  2. github

Select Repository Type: 1 Selected Repository Type: cloudpi Creating project “javawj”: .….……OK

ubuntu@admin:~$ pi upload

Project Name=======
  1. javatestgithub

  2. javawj

Select Project: 2 Selected Project: javawj Please enter the version: paashelp Please enter in the description: paashelp Please enter the path of upload war file: /home/wangjing/paashelp.war Uploading “paashelp.war”: .OK

ubuntu@admin:~$ pi project-apps

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 4 Selected Project: railswj ------------———–-----------------------------------------------——–---------———–+ | Target | AppName | URL | Tag | Status | Instances | ------------———–-----------------------------------------------——–---------———–+ | ap-ne-test | railsdemo | railsdemo.wangjing.ap-ne-test.samsungpaas.com | v0.0.0 | STARTED | 1 | ------------———–-----------------------------------------------——–---------———–+

ubuntu@admin:~$ pi create-app Application Name: javaapp

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Versions============
  1. paashelp

Select Version: 1 Selected Version: paashelp

Targets============
  1. ap-ne-test-ap-ne-test.samsungcloud.org

Select Target: 1 Selected Target: ap-ne-test-ap-ne-test.samsungcloud.org Available memory: 6080 M URL: javaapp.wangjing.ap-ne-test.samsungpaas.com Memory reservation (64M, 128M, 256M, 512M, 1G, 2G) [64M]: How many instances? [1]: Need debug? [yN]: Need restart? [yN]: Need monitor? [yN]: Branch: master Creating application “javaapp”: .….….….….….….….….….…..OK

ubuntu@admin:~$ pi apps

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj ------------———----------------------------------------------————-----------———-----------——————-+ | Target | App name | URL | Deploy Type | Version | Status | Instances | Running Instances | ------------———----------------------------------------------————-----------———-----------——————-+ | ap-ne-test | javaapp | javaapp.wangjing.ap-ne-test.samsungpaas.com | binary | paashelp | STARTED | 1 | 1 | ------------———----------------------------------------------————-----------———-----------——————-+

ubuntu@admin:~$ pi stop-app

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Stoping application: OK

ubuntu@admin:~$ pi start-app

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Starting application: .….….….….….….……OK

ubuntu@admin:~$ pi status

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp -------------———--------———–---------————–------------ | Instance ID | Status | CPU(%) | Memory(M) | Disk(M) | RequestCount | ErrorCount | -------------———--------———–---------————–------------ | 5531b2 | running | 21.393 | 258 | 52 | 0 | 0 | | 882a94 | dead | 0 | 0 | 0 | 0 | 0 | -------------———--------———–---------————–------------

ubuntu@admin:~$ pi scale-app

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp How many instances? [1]: 2 Scaling application: .….….….….….OK

ubuntu@admin:~$ pi app-log

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Select instance index(from 0 to 1) [0]: 0 1: stderr.log 914B 2: stdout.log 0B Select logs, indexed list?: 1 Selected logs: stderr.log

Jul 20, 2012 7:25:52 AM org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-39652 Jul 20, 2012 7:25:52 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1155 ms Jul 20, 2012 7:25:52 AM org.apache.catalina.core.StandardService start INFO: Starting service Catalina Jul 20, 2012 7:25:52 AM org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.32 Jul 20, 2012 7:25:52 AM org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive probe.war Jul 20, 2012 7:25:57 AM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT Jul 20, 2012 7:25:57 AM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-39652 Jul 20, 2012 7:25:57 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 5332 ms

ubuntu@admin:~$ pi create-env

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Environment Name: aa Environment Value: bb OK

ubuntu@admin:~$ pi app-env

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp ------——-+ | Name | Value | ------——-+ | aa | bb | ------——-+

ubuntu@admin:~$ pi delete-env

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Environment Name: aa OK

ubuntu@admin:~$ pi map-dns

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp 1: dnswj.samsungpaas.com Select dns, indexed list?: 1 Selected dns: dnswj.samsungpaas.com Mapping dns: ..OK

ubuntu@admin:~$ pi app-dns

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp ----------------------- | Mapped DNS Name | ----------------------- | dnswj.samsungpaas.com | -----------------------

ubuntu@admin:~$ pi unmap-dns

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp

DNS============
  1. dnswj.samsungpaas.com

Select DNS: 1 Selected DNS: dnswj.samsungpaas.com Unmapping dns: ..OK

ubuntu@admin:~$ pi bind-service

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp 1: mysql_demo_251_cloudpi-dedicated-mysql_wangjing Select services, indexed list?: 1 Selected services: mysql_demo_251_cloudpi-dedicated-mysql_wangjing Binding service: .….….….….….….……OK

ubuntu@admin:~$ pi app-service

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp -------------------------------------------------———----------- | Name | Version | Type | -------------------------------------------------———----------- | mysql_demo_251_cloudpi-dedicated-mysql_wangjing | 5.1.410 | dedicated | -------------------------------------------------———-----------

ubuntu@admin:~$ pi unbind-service

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp

Services============
  1. mysql_demo_251_cloudpi-dedicated-mysql_wangjing

Select Service: 1 Selected Service: mysql_demo_251_cloudpi-dedicated-mysql_wangjing Unbinding service: .….….….….….….….….….….….……OK

ubuntu@admin:~$ pi project-events

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj ------------———-----------------------———–------------------------------------ | Target | AppName | EventTime | EventInfo | EventDetail | ------------———-----------------------———–------------------------------------ | | | 2012-07-20 07:22:06.0 | INFO | Success to create project : javawj | | ap-ne-test | javaapp | 2012-07-20 07:24:48.0 | INFO | Success to create appliation. | | ap-ne-test | javaapp | 2012-07-20 07:25:34.0 | INFO | Success to stop application. | | ap-ne-test | javaapp | 2012-07-20 07:26:01.0 | INFO | Success to start application. | | ap-ne-test | javaapp | 2012-07-20 07:30:25.0 | INFO | Success to scale instances to 2 | | ap-ne-test | javaapp | 2012-07-20 07:31:55.0 | INFO | Success to add env : aa=bb | | ap-ne-test | javaapp | 2012-07-20 07:32:28.0 | INFO | Success to delete env. | | ap-ne-test | javaapp | 2012-07-20 07:33:47.0 | INFO | Success to map url. | | ap-ne-test | javaapp | 2012-07-20 07:34:12.0 | INFO | Success to unmap url. | | ap-ne-test | javaapp | 2012-07-20 07:35:10.0 | INFO | Success to stop application. | | ap-ne-test | javaapp | 2012-07-20 07:35:38.0 | INFO | Success to bind service. | | ap-ne-test | javaapp | 2012-07-20 07:36:09.0 | INFO | Success to stop application. | | ap-ne-test | javaapp | 2012-07-20 07:36:27.0 | INFO | Success to unbind service. | ------------———-----------------------———–------------------------------------

ubuntu@admin:~$ pi project-tags

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 4 Selected Project: railswj

-------- | Tag | -------- | v0.0.0 | --------

ubuntu@admin:~$ pi project-commits

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 4 Selected Project: railswj

Tag=======
  1. v0.0.0

Select Tag: 1 Selected Tag: v0.0.0 ------------------------------------------—————————-------------- | CommitId | Date | Comment | ------------------------------------------—————————-------------- | d0275d482edca5dbcbaee9baa7acfcd8ed01ab60 | 2012-07-18 11:08:02 +0000 | init project | ------------------------------------------—————————--------------

ubuntu@admin:~$ pi delete-app

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj

Application Name===========
  1. javaapp

Select Application: 1 Selected Application: javaapp Deleting application: ..OK

ubuntu@admin:~$ pi delete-project

Project Name===========
  1. javatestgithub

  2. javawj

  3. railstestgithub

  4. railswj

Select Project: 2 Selected Project: javawj Deleting project “javawj”: .…..OK

ubuntu@admin:~$ pi logout Successfully logged out of [api.staging.samsungcloud.org]

  1. Common Exception

ubuntu@admin:~$ pi login Attempting login to ‘api.staging.samsungcloud.org’? [Yn]: n Please input URL: test.org User: wangjing Password: ******* Problem with login, Cannot access target (getaddrinfo: Name or service not known), try again or register for an account.

ubuntu@admin:~$ pi github Please input your name: ruanzhimin Please input your email: [email protected] Please input your password: ***

Error (1007): Invalid github account.

ubuntu@admin:~$ pi project-events tmp4

Error (3004): The project is not belongs to current account.Project name : tmp4