This guide is for a user who want to use CloudUnit with command line interface.
For use this application, you need to have installed before :
- Available CloudUnit Manager 1.0
- Java Runtime Environment 1.7 or more
You can download the archive of application here. Or use :
git clone git@github.com:Treeptik/CloudUnit-CLI.gitAfter download, you can launch the application by using these commands :
cd CloudUnit-CLI
mvn clean compile exec:javaYou can run this application with Docker too :
docker run --rm -it cloudunit/cliWhen the application is running, you can access to help with the command help. This command will display all commands available in CloudUnit-CLI.
cloudunit-cli> helpIf you wanna have an help on a specific command, you can use help with command in argument :
cloudunit-DEV-myapp> help connect
Keyword: connect
Description: Connect to CloudUnit Host
Keyword: login
Help: Your login
Mandatory: true
Default if specified: '__NULL__'
Default if unspecified: '__NULL__'
Keyword: password
Help: User password
Mandatory: false
Default if specified: '__NULL__'
Default if unspecified: ''
Keyword: host
Help: Host for Cloudunit Platform
Mandatory: false
Default if specified: '__NULL__'
Default if unspecified: ''
* connect - Connect to CloudUnit HostIf you give a pattern in argument, the help command provides you commands with this pattern :
cloudunit-DEV-myapp> help rm
* rm-alias - Remove an existing alias
* rm-app - Remove an application
* rm-module - Remove a module from the current application
* rm-snapshot - Remove the snapshot for the current applicationYou can connect to the CloudUnit Manager with the command :
cloudunit-cli> connect --login johndoe
Enter your password :
*******
Trying to connect to default CloudUnit host...
Connection establishedDefault host is localhost(/127.0.0.1) but you can specify if you want an external host with the command :
cloudunit-cli> connect --login johndoe --host https://admin.cloudunit.dev
Enter your password :
*******
Trying to connect to default CloudUnit host...
Connection establishedNow you are in the DEV context.
You can create an application with the command :
cloudunit-DEV> create-app --name name --type tomcat-7
Your application myapp is currently being installedAfter this command, you are in the application context.
You can delete an existing application :
cloudunit-DEV-myapp> rm-app --name test
test
Confirm the suppression of your application: test - (yes/y) or (no/n)
yes
Your application test is currently being removedWhen you have two or more applications created on CloudUnit, you can take control of an application with the command :
cloudunit-DEV-myapp> use myapp2
Current application : myapp2For this feature, you must have already created a snapshot. You can clone an existing application :
cloudunit-DEV-myapp> clone --tag tag --applicationName myapp
Your application myapp2 was successfully created.You can display all informations about the current application :
cloudunit-DEV-myapp> informations
GENERAL
+----------------+--------+----------------+-----------+------+------------+
|APPLICATION NAME|AUTHOR |STARTING DATE |SERVER TYPE|STATUS|JAVA VERSION|
+----------------+--------+----------------+-----------+------+------------+
|myapp |Doe John|2016-06-03 13:23|TOMCAT-7 |START |jdk1.7.0_55 |
+----------------+--------+----------------+-----------+------+------------+
GIT ADDRESS
+----+--------------+
|TYPE|REMOTE ADDRESS|
+----+--------------+
|GIT |(NULL) |
+----+--------------+
SERVER INFORMATION
+--------+-------------+--------+------+--------+------+---------------------------------------------------------------+
|TYPE |ADDRESS |SSH PORT|STATUS|JVM OPTS|MEMORY|MANAGER LOCATION |
+--------+-------------+--------+------+--------+------+---------------------------------------------------------------+
|TOMCAT-7|cloudunit.dev|32774 |FAIL |NONE |1024 |http://manager-myapp-johndoe-admin.cloudunit.dev/manager/html? |
+--------+-------------+--------+------+--------+------+---------------------------------------------------------------+
MODULES INFORMATION
No modules found!
TerminatedYou can list all applications :
cloudunit-DEV> list-apps
+----------------+--------+----------------+-----------+------+
|APPLICATION NAME|AUTHOR |STARTING DATE |SERVER TYPE|STATUS|
+----------------+--------+----------------+-----------+------+
|test |Doe John|2016-06-03 11:00|jboss-8 |START |
+----------------+--------+----------------+-----------+------+
|myapp |Doe John|2016-06-03 13:23|tomcat-7 |START |
+----------------+--------+----------------+-----------+------+
|myapp2 |Doe John|2016-06-03 13:48|tomcat-6 |START |
+----------------+--------+----------------+-----------+------+
|myapp3 |Doe John|2016-06-03 14:07|tomcat-7 |START |
+----------------+--------+----------------+-----------+------+
|myapp4 |Doe John|2016-06-03 14:32|tomcat-7 |STOP |
+----------------+--------+----------------+-----------+------+
|myapp5 |Doe John|2016-06-03 15:02|tomcat-6 |START |
+----------------+--------+----------------+-----------+------+
6 found !You can start the application with start command. This command starts all services of this application too :
cloudunit-DEV-myapp> start
Your application myapp is currently being startedAfter your application was started, you can stop it and its services with stop command :
cloudunit-DEV-myapp> stop
Your application myapp is currently being stoppedYou can list all containers of an application :
cloudunit-DEV-test> list-containers
+-------------------------+
|CONTAINER NAME |
+-------------------------+
|dev-johndoe-test-tomcat-6|
+-------------------------+
1 containers found!You can create an environment variable to an application with this command :
cloudunit-DEV-test> create-var-env --key key --value value
test
An environment variable has been successfully added to testAccents and specials characters are forbbiden in keys.
You can remove an environment variable if you use the command rm-var-env :
cloudunit-DEV-test> rm-var-env --key key
This environment variable has successful been deletedYou can list all environment variables of an application :
cloudunit-DEV-test> list-var-env
+-----------------------------+------+
|CURRENT ENVIRONMENT VARIABLES|VALUES|
+-----------------------------+------+
|key |value |
+-----------------------------+------+
1 variables found!You can update a environment variable by modifying key, value or both.
cloudunit-DEV-test> update-var-env --old-key key --new-key keyUpdated --value valueUpdated
This environment variable has successful been updatedYou can add an alias to an application with this command :
cloudunit> add-alias --alias treeptik.fr
An alias has been successfully added to myappAliases must to respect some pattern (treeptik.fr, treeptik-test.fr, treeptik123.corp.eu)
You can remove an alias if you use the command rm-alias :
rm-alias --alias treeptik.fr
This alias has successful been deletedYou can list all aliases of an application :
cloudunit-DEV-myapp> list-aliases
+---------------+
|CURRENT ALIASES|
+---------------+
|treeptik.fr |
+---------------+
1 aliases found!You can open a port :
cloudunit-DEV-myapp> open-port --name port --port 8080 --nature http
portYou can remove a opened port :
cloudunit-DEV-myapp> remove-port --name port --port 8080
portYou can add Java options (except memory options) to an application with this command :
cloudunit-DEV-myapp> add-jvm-option "option"
Add java options to myapp application successfullyYou can change option of Java in your application :
- Change the version of Java which your application use :
cloudunit-DEV-myapp> change-java-version --javaVersion java7
Your java version has been successfully changedYou have access to three versions of Java : java7, java8 and java9
- Change the memory used by Java :
cloudunit-DEV-myapp> change-jvm-memory --size 512
Change memory on myapp successfulYou have four options for memory : 512, 1024, 2048, 3072. By default, an application has memory of 512.
You can add a module on your application with this command :
cloudunit-DEV-myapp> add-module --name mysql-5-5
myapp
Your module mysql-5-5 is currently being added to your application myappYou have four modules available : MySQL 5.5 (mysql-5-5), POSTGRES 9.3 (postgres-9-3), REDIS 3.0 (redis-3-0), MONGO 2.6 (mongo-2-6).
You can remove a existing module in an application :
cloudunit-DEV-myapp> rm-module --name mysql-5-5
myapp
Your module mysql-5-5 is currently being removed from your application myappYou can display informations about all modules of an application with the command display-modules :
cloudunit-DEV-myapp> display-modules
MODULES INFORMATION
+-----------+---------------------------------------------------------------+
|MODULE NAME|mysql-5-5-1 |
+-----------+---------------------------------------------------------------+
|TYPE |mysql-5-5 |
+-----------+---------------------------------------------------------------+
|DOMAIN NAME|johndoe-myapp-mysql-5-5-1.mysql-5-5.cloud.unit |
+-----------+---------------------------------------------------------------+
|PORT |3306 |
+-----------+---------------------------------------------------------------+
|USERNAME |adminom8cdo5u |
+-----------+---------------------------------------------------------------+
|PASSWORD |p3v19ir0 |
+-----------+---------------------------------------------------------------+
|DATABASE |myapp |
+-----------+---------------------------------------------------------------+
|MANAGER |http://phpmyadmin1-myapp-johndoe-admin.cloudunit.dev/phpmyadmin|
+-----------+---------------------------------------------------------------+You can create a snapshot of an application using :
cloudunit-DEV-myapp> create-snapshot --tag tag1 --applicationName myapp
myapp
A new snapshot called tag1 was successfully created.You can delete a snapshot of an application :
cloudunit-DEV> rm-snapshot --tag tag1
The snapshot tag1 was successfully deleted.If an application use the template which you want to remove :
cloudunit-DEV-myapp> rm-snapshot --tag tag1
At least one application uses this template. You must delete it before.You can list all snapshots of an application :
cloudunit-DEV-myapp> list-snapshot
No snapshots found!
0 snapshots foundYou can deploy an archive on your application. This archive have to be in ear or war file type.
cloudunit-DEV-myapp> deploy --path ~/cloudunit-webapp-examples/pizzaiolo-mysql/target/pizzashop-1.0.0.war --openBrowser true
War deployed - Access on http://myapp-johndoe-admin.cloudunit.devYou can list all command files in a container with this command :
cloudunit-DEV-test> list-commands --container-name dev-johndoe-test-wildfly-8
+--------------------+------------------------+-----------+
|CURRENT COMMAND |ARGUMENT NUMBER REQUIRED|ARGUMENTS |
+--------------------+------------------------+-----------+
|create_datasource.sh|2 |NAME DRIVER|
+--------------------+------------------------+-----------+
1 commands found!You can create a volume with this command :
cloudunit-DEV> create-volume --name volumeTest
The volume volumeTest was been successfully createdYou can remove a volume :
cloudunit-DEV> rm-volume --name volumeTest
This volume has successful been deletedWhen you have created your volume, you can mount it on an existant application (You must use an absolute path for this command) :
cloudunit-DEV-test> mount-volume --volume-name volumeTest --path /cloudunit/ --container-name dev-johndoe-test-tomcat-6 --application-name test
This volume has successful been mountedOnce your volume mount on your application, you can unmount it with the command :
cloudunit-DEV-test> unmount-volume --container-name dev-johndoe-test-tomcat-6 --volume-name volumeTest
This volume has successful been unmountedYou can clear the console by two ways :
cloudunit-DEV-myapp> clearcloudunit-DEV-myapp> clsYou can have the current date and time :
cloudunit-DEV-myapp> date
vendredi 3 juin 2016 14 h 34 CESTFor get this informations, you need to use the command echo :
cloudunit-DEV-myapp> echo
0You can see all shell's variables with the command shell properties :
cloudunit-DEV-myapp> system properties
awt.toolkit = sun.awt.X11.XToolkit
classworlds.conf = /usr/share/maven/bin/m2.conf
...
user.language = fr
user.name = username
user.timezone = Europe/ParisYou can the version of CloudUnit CLI with the command version :
cloudunit-DEV-myapp> version
1.0If you use ! before a command, the shell executes the command like an OS command :
cloudunit-DEV-myapp> ! echo "Hello World !"
command is:echo "Hello World !"
"Hello World !"If you wanna execute some commands in a file, you can use the command script :
cloudunit-cli> script --file ../../Connect.sh
connect --login johndoe --password abc2015
Trying to connect to default CloudUnit host...
Connection established
Script required 0.731 seconds to executeYou can only execute commands available on CloudUnit-CLI, not OS commands.
The // and ; characters, if these characters start lines, allow to print comments :
cloudunit-DEV-myapp> // Remove an application
cloudunit-DEV-myapp> ; Remove an application
cloudunit-DEV-myapp> rm-app --name myapp
myapp
Confirm the suppression of your application: myapp - (yes/y) or (no/n)
yes
Your application myapp is currently being removedFor exit CloudUnit-CLI and return the standard shell, you need to use this command :
cloudunit-DEV-myapp> exitYou can use the command quit too :
cloudunit-DEV-myapp> quitYou can disconnect with the command disconnect :
cloudunit-DEV-myapp> disconnect
DisconnectThis is an exemple of script which connect to an account, create an application, download a git repository, package it and deploy it on CloudUnit-CLI :
connect --login johndoe --password abc2015
create-app --name myapp --type tomcat-7
! git clone https://github.com/Treeptik/cloudunit-webapp-examples.git
! mvn clean package -f cloudunit-webapp-examples/spring-boot-mongodb/pom.xml
deploy --path cloudunit-webapp-examples/spring-boot-mongodb/
disconnectNow, you'll just run the command :
cloudunit-cli> script --file /home/username/script.sh