require 'paint' # list commands and display help # module App42 module Base class Help # # details how to use app42 commands # def self.how_to Paint["Usage: app42 COMMAND [command-specific-options]", :blue] end # # list available commands or display help for a specific command # def self.commands print <<-USAGE #{how_to} Key keys # List API key and Secret key addKeys # Add API key and Secret key clearKeys # Clear API key and Secret key Applications setupInfra # Setup your deployment and runtime environment i.e. Instance(Memory, CPU) and Technology Stack deploy # Deploy the application over your runtime environment scale # Scale application by number of instance(s) descale # Descale application by number of instance(s) start # Start the application stop # Stop the application restart # Restart the application deleteInfra # Delete the Infrastructure environment apps # List all the deployed applications with their meta details appInfo # Show meta information of the application appState # Show current state of the application logs # Returns the log file URLs for the application Services createService # Creates a new service e.g. MySQL, MongoDB, CouchDB, PostgreSQL etc. deleteService # Delete provisioned service services # List all the provisioned services with their meta details serviceInfo # Show meta information of the provisioned service resetServicePassword # Reset password of provisioned service bindIP # Bind IP to provisioned service unbindIP # Unbind IP from provisioned service bindInfo # Show IP bind information related to provisioned service Misc supportedServices # List supported services by App42 iaasProviders # List supported IaaS providers by App42 runtimes # List supported runtimes by App42 Help version # Show Ruby client gem version help # List available commands and their description COMMAND --help # Display detailed help of a specific command USAGE end def self.keys_help print <<-USAGE #{how_to} app42 api_key:add [KEY] # add a api key for the current user app42 secret_key:add [KEY] # add a Secret Key for the current user app42 keys:clear # remove all authentication keys from the current user USAGE end # call help methods def Help.usage command if self.respond_to?(command) send command elsif self.respond_to?(command.split(':').last) send command.split(':').last elsif self.respond_to?(command.split('-').join('_')) send command.split('-').join('_') else Paint["Sorry..!!, Help is not available.\n", :red] end end class << self def keys print <<-DESC Usage: app42 keys List API key and Secret key Example: === API/Secret Key === API Key = Secret Key = DESC end def addKeys print <<-DESC Usage: app42 addKeys Add API key and Secret key Options: [--apiKey=API_KEY] # API Key to add. [--secretKey=SECRET_KEY] # Secret Key to add. Example: $app42 addKeys == Enter your App42PaaS keys == Enter API Key:: Enter Secret Key:: Adding keys...done DESC end def clearKeys print <<-DESC Usage: app42 clearKeys Clear API key and Secret key from dev system Example: app42 clearKeys == Local credentials cleared == DESC end def setupInfra print <<-DESC Usage: app42 setupInfra Setup the complete runtime environment Example: $app42 setupInfra 1: Shared Select Virtual Machine Type: 1 1: Amazon Select IaaS Provider: 1 Application Name: demo Checking App Name Availability... OK 1: Ruby 2: Java 3: Php 4: Node Select Runtime: 2 1: Grails 1.3.7 Select Framework: 1 1: Tomcat 6.0.36 Select Web Server: 1 1: 512MB 2: 1024MB 3: 2048MB Memory Limit: 1 Creating Infrastructure... OK Latest Status....| Setup Infrastructure successfully done. Default Application Deployed. URL is : demo.aws.app42paas.com DESC end def apps print <<-DESC Usage: app42 apps Deploy the application over runtime environment Example: $app42 apps +------------------------+------------+-----------------+---------------+---------+------+ | === My Apps === | +------------------------+------------+-----------------+---------------+---------+------+ | App Url | App Status | Container Count | Iaas Provider | Vm Type | Name | +------------------------+------------+-----------------+---------------+---------+------+ | demo.aws.app42paas.com | RUNNING | 1 | Amazon | Shared | demo | +------------------------+------------+-----------------+---------------+---------+------+ DESC end def deploy print <<-DESC Usage: app42 deploy Deploy application Options: [--app APP] # Name of app, you want to update Example: $app42 deploy Enter App Name: demo Would you like to deploy from the current directory? [Yn]: n Binary Deployment Path: /home/ubuntu/workspace/Deploycode/ruby Deploying Application... OK Latest Status....| 1 out of 1 Uploaded Application deployed successfully. DESC end def update print <<-DESC Usage: app42 update Update existing application Options: [--app APP] # Name of app, you want to update Example: $app42 update Enter App Name: demo Would you like to deploy from the current directory? [Yn]: n Binary Deployment Path: /home/ubuntu/workspace/Deploycode/ruby Deploying Application... OK Latest Status....| 1 out of 1 Uploaded Application deployed successfully. DESC end def start print <<-DESC Usage: app42 start Start the application Options: [--app APP] # Name of app, you want to start Example: $app42 start --app demo Starting app demo ...Done DESC end def stop print <<-DESC Usage: app42 stop Stop the application Options: [--app APP] # Name of app, you want to stop Example: $app42 stop --app demo Stopping app demo ...Done DESC end def restart print <<-DESC Usage: app42 restart Restart the application Options: [--app APP] # Name of app, you want to restart Example: $app42 start --app demo Restarting app demo ...Done DESC end def deleteInfra print <<-DESC Usage: app42 deleteInfra Delete the Infrastructure environment Options: [--app APP] # Name of app, you want to delete Example: $app42 deleteInfra --app demo Deleting app demo ...Done DESC end def descale print <<-DESC Usage: app42 descale Descale application by number of instance(s) Options: [--app APP] # Name of app, you want to descale Example: $app42 descale --app demo Descale by instance(s): 1 Descaling Application demo by instance 1... OK Please wait... It may take few minutes to complete. Latest Status....| Descale completed successfully. DESC end def scale print <<-DESC Usage: app42 scale Scale application by number of instance(s) Options: [--app APP] # Name of app, you want to scale Example: $app42 scale --app demo Scale by instance(s): 1 Scaling Application demo by instance 1... OK Please wait... It may take few minutes to complete. Latest Status....| Scale completed successfully. DESC end def appInfo print <<-DESC Usage: app42 appInfo Show the meta information of the application Options: [--app APP] # Name of app, you want to info Example: $app42 appInfo --app demo Application Name: demo +------------------------+------------+---------------+------+----------+----------------+--------+ | === demo Info === | +------------------------+------------+---------------+------+----------+----------------+--------+ | App Url | App Status | Iaas Provider | Name | Runtime | Instance Count | Memory | +------------------------+------------+---------------+------+----------+----------------+--------+ | demo.aws.app42paas.com | RUNNING | Amazon | demo | Ruby 2.0 | 1 | 512 MB | +------------------------+------------+---------------+------+----------+----------------+--------+ DESC end def appState print <<-DESC Usage: app42 appState Show current state of the application Options: [--app APP] # Name of app Example: $app42 appState --app demo +--------------------+ | === demo State === | +--------------------+ | RUNNING | +--------------------+ DESC end def logs print <<-DESC Usage: app42 logs Returns the log URLs for the application Example: $app42 logs Enter App Name: demo Please visit below URL(s) to access app logs +----------------------------------------------------------------------------+ | Log URL(s) | +----------------------------------------------------------------------------+ | demo.aws.app42paas.com/getInstanceLog?id=fi1nyi7bh68nvz0riyqrfup8lkm57qiu | | demo.aws.app42paas.com/getInstanceLog?id=v1bta5rg2tsycat31r3pzc28sa7d1bjy | +----------------------------------------------------------------------------+ DESC end def createService print <<-DESC Usage: app42 createService Creates a new service Example: $app42 createService 1: Mysql 2: Mongodb Select Service: 1 Enter Service Name: mysql-demo Enter Database Name: demo_dev 1: Shared Select Virtual Machine Type: 1 1: Amazon Select IaaS Provider: 1 1: 512MB 2: 1024MB 3: 2048MB Memory Limit: 1 Creating Service... OK Latest Status....| Service successfully created. +---------------+---------------+---------+---------------+------------------+---------+--------------+----------------------------------+--------------+ | === mysql-demo Details === | +---------------+---------------+---------+---------------+------------------+---------+--------------+----------------------------------+--------------+ | Database Name | Iaas Provider | Vm Type | Vm Ip | User Name | Vm Port | Service Type | Password | Service Name | +---------------+---------------+---------+---------------+------------------+---------+--------------+----------------------------------+--------------+ | demo_dev | Amazon | Shared | xx.yyy.zzz.aa | xxxxxxxxxxxxxxxx | 45074 | mysql55 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | mysql-demo | +---------------+---------------+---------+---------------+------------------+---------+--------------+----------------------------------+--------------+ DESC end def deleteService print <<-DESC Usage: app42 deleteService Delete the provisioned service Options: [--service SERVICE] # Name of service Example: $app42 deleteService 1: mysql-demo 2: mysql-test Select Service: 1 Latest Status....- 1 out of 1 deleted Service mysql-demo successfully deleted. DESC end def services print <<-DESC Usage: app42 services List the all provisioned services with their meta details Example: $app42 services +---------------+---------+----------+--------------+ | === Service List === | +---------------+---------+----------+--------------+ | Iaas Provider | Vm Type | Name | Service Type | +---------------+---------+----------+--------------+ | Amazon | Shared | demo_dev | mysql55 | +---------------+---------+----------+--------------+ DESC end def serviceInfo print <<-DESC Usage: app42 serviceInfo Show the meta information of the provisioned service Options: [--service SERVICE] # Name of service Example: $app42 serviceInfo 1: mysqldemo Select Service: 1 +---------------+---------------+-----------+---------+------------------+---------+--------------+----------------------------------+--------+--------------+ | === mysqldemo Details === | +---------------+---------------+-----------+---------+------------------+---------+--------------+----------------------------------+--------+--------------+ | Database Name | Iaas Provider | Vm Ip | State | User Name | Vm Port | Service Type | Password | Memory | Service Name | +---------------+---------------+-----------+---------+------------------+---------+--------------+----------------------------------+--------+--------------+ | demodb | Amazon | 10.0.0.52 | RUNNING | 5hk1tmdmkr16b94f | 52108 | MySQL 5.5.1 | 2otwxwpu8mskmmvwt7bx4r2fzw4ytls0 | 512 MB | mysqldemo | +---------------+---------------+-----------+---------+------------------+---------+--------------+----------------------------------+--------+--------------+ DESC end def supportedServices print <<-DESC Usage: app42 supportedServices List the supported services by App42 Example: $app42 supportedServices +--------------+-----------------+ | === App42 PaaS Services === | +--------------+-----------------+ | Name | Service Version | +--------------+-----------------+ | Mysql | 5.5.1 | | Mongodb | 2.4 | +--------------+-----------------+ DESC end def runtimes print <<-DESC Usage: app42 runtimes List the supported runtimes Example: $app42 runtimes +--------------+--------------+ | === Available Runtimes === | +--------------+--------------+ | Name | Version | +--------------+--------------+ | Ruby | 2.0 | | Java | 6.0 | | Java | 7.0 | | Php | 5.5 | +--------------+--------------+ DESC end def iaasProviders print <<-DESC Usage: app42 iaasProviders List the supported IaaS providers by App42 Example: $app42 iaasProviders +-----------------+-----------------+ | === Available IaaS Providers === | +-----------------+-----------------+ | Name | Zone | +-----------------+-----------------+ | Amazon | US West-2a | +-----------------+-----------------+ DESC end def app42_update print <<-DESC Usage: app42 app42-update Update App42PaaS client(app42) -> Download app42 client, In a terminal, go to the folder where you have downloaded the client and run client update command. Example: $app42 app42-update Uninstalling current app42 client Remove executables: app42 in addition to the gem? [Yn] y Removing app42 Successfully uninstalled app42-0.5.0 Installing latest app42 client Successfully installed app42-0.5.0 1 gem installed Installing ri documentation for app42-0.5.0... Installing RDoc documentation for app42-0.5.0... DESC end def resetServicePassword print <<-DESC Usage: resetServicePassword Reset the password of provisioned service Example: $resetServicePassword Enter Service Name: mysql_demo Enter Old Password: 1pc8a09ise98nutrqzouj5ya98vtd08y Resetting Password... OK Please wait it may takes few minutes. Latest Status.... Reset Password successful.Your new password is: quzg6bogsu0ak3rwyr0egs8a1ttgc9tt DESC end def bindIP print <<-DESC Usage: app42 bindIP Bind IP to a service Example: $app42 bindIP Enter Service Name: mysql_demo Please Provide Source IP (0.0.0.0, for public access): 0.0.0.0/0 Please provide the time duration you want to access service(0 for unlimited access[in hours]): 2 Binding IP to service... OK Please wait it may takes few minutes. Latest Status....| Bind service successful. +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | === mysql_demo Details === | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | Database Name | Os | Iaas Provider | Vm Type | Vm Ip | Source Ip | User Name | Vm Port | Service Type | Password | Memory | Service Name | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | demo_development | Ubuntu 12.10 | Amazon | Shared | 54.218.127.245 | 0.0.0.0/0 | 4gxu2btjrh7p1ku5 | 20830 | MySQL 5.5.1 | c8f6ynn0p065wzh7i2802pi5nfpfyr58 | 512 MB | mysql_demo | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ DESC end def unbindIP print <<-DESC Usage: app42 unbindIP Unbind service from the application Example: $app42 unbindIP Enter Service Name: mysql_demo Please Provide Source IP (0.0.0.0, for public access): 0.0.0.0/0 Unbinding IP to service... OK Please wait it may takes few minutes. Latest Status....- Unbind service successful. DESC end def bindInfo print <<-DESC Usage: app42 bindInfo Show IP bind information Example: $app42 bindInfo 1: mysql_demo Select Service: 1 +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | === mysql_demo Details === | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | Database Name | Os | Iaas Provider | Vm Type | Vm Ip | Source Ip | User Name | Vm Port | Service Type | Password | Memory | Service Name | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ | demo_development | Ubuntu 12.10 | Amazon | Shared | 54.218.127.245 | 0.0.0.0/0 | 4gxu2btjrh7p1ku5 | 20830 | MySQL 5.5.1 | c8f6ynn0p065wzh7i2802pi5nfpfyr58 | 512 MB | mysql_demo | +------------------+--------------+---------------+---------+----------------+-----------+------------------+---------+--------------+----------------------------------+--------+--------------+ DESC end def version print <<-DESC Usage: app42 version Show Ruby client gem version Example: $app42 version App42 current version: 0.5.3 DESC end end end end end