Connecting to application console
You can connect to the console of your application.
While creating your profile, if the SSH_PORT is configured, ioxclient
automatically tries to connect and drop you into a shell connected to applications console. If the port is not configured, then it prints out a template command that you can execute using a ssh client.
$ ./ioxclient application console py
Currently active profile : default
Command Name: application-console
Console setup is complete..
The device's SSH port is not configured! Cannot auto connect!Please run the below command :
ssh -p {SSH_PORT} -i py.pem appconsole@127.0.0.1
SSH_PORT is the ssh port on which the SSH server on the device is bound. Note that it can be a non standard port depending on the NAT rules configured on the device.
If the SSH_PORT is configured correctly, you will be automatically connected. Hit Ctrl+C
to exit.
$ ./ioxclient application console py
Currently active profile : local
Command Name: application-console
Console setup is complete..
Attempting to automatically connect.., press Ctrl+C to exit
Connecting to appconsole@127.0.0.1:22 using pem file py.pem
Connected to domain py
Escape character is ^]
root@ir800-lxc:~# ps
ps
PID USER VSZ STAT COMMAND
1 root 4208 S init [5]
118 root 7784 S udhcpc -R -b -p /var/run/udhcpc.eth0.pid -i eth0
122 root 7784 S {startcontainer.} /bin/sh /bin/startcontainer.sh
127 root 294m S python /appdir/app/main.py
139 root 7784 S /sbin/syslogd -n -O /var/log/messages
142 root 7784 S /sbin/klogd -n
145 root 12012 S -sh
5274 root 7784 S /sbin/getty 38400 tty2
5275 root 10548 S ping -c 1 www.google.com
5276 root 12012 R ps
root@ir800-lxc:~# ^C
$
New Shell Session in Container
One can also create a new shell session in docker containers using the below command.
While creating your profile, if SSH_PORT was configured correctly, ioxclient
automatically tries to connect and drop you into a new shell session inside the container. If the port is not configured, then it prints out a template command that you can execute using a ssh client.
If the SSH_PORT is configured correctly, you will be automatically connected. Hit Ctrl+D
to exit.
dev:~/Documents/cisco/iox_apps/> ioxclient app session docker_app
Currently active profile : Callisto
Command Name: application-session
Console setup is complete..
Running command : [ssh -p 2222 -i docker_app.pem appconsole@10.78.106.50]
/ # ps
PID USER TIME COMMAND
1 root 0:00 /bin/sleep 10000000
31 root 0:00 /bin/sh
37 root 0:00 ps
/ #
Getting application metrics
The metrics command shows the resources used by the application.
~$ ioxclient application metrics nettest
Currently using profile : default
Command Name: application-metrics
Host ID : 564D7AD1-641A-3FC3-0C41-3313E82D27AB
-------------------Resource usage by app------------------
AppID : nettest, RUNNING
memory (current, in KB) : 6688
cpu (current, in percent) : 0.01
network (current, in bytes) : 99601
disk (current, in MB) : 0.03
Stopping the application
~/projects/sample-apps-v2/paas/python/nettest$ ioxclient application stop nettest
Currently using profile : default
Command Name: application-stop
App nettest is Stopped
Deactivating the application
~/projects/sample-apps-v2/paas/python/nettest$ ioxclient application deactivate nettest
Currently using profile : default
Command Name: application-deactivate
App nettest is Deactivated
Upgrading the application
$ ioxclient application upgrade nettest app.tar.gz
Currently using profile : default
Command Name: application-upgrade
Preserve app data across upgrade(y/N)? [y] :
Upgrade Successful. App is available at : https://127.0.0.1:8443/iox/api/v2/hosting/apps/ioxclient_test_app/nettest
Upgrade successful.
Uninstalling the application
$ ioxclient application uninstall nettest
Currently using profile : default
Command Name: application-uninstall
Successfully uninstalled app nettest
Install, activate, and start application in one shot
The run command combines all the steps to reach a running application in one command. A package must be specified to install, activate, and start. Additionally a specific activation payload can be given to customize the resources upon activation.
To run an app directly from a docker image, see the sample below for command usage:
ioxclient application run --payload activationpayload --docker-opts "--dns 8.8.8.8" appid docker_image [optional project dir containing package related files]
To run an app from an IOx package, see the sample below for command usage:
ioxclient application run --payload activationpayload --docker-opts "--dns 8.8.8.8" appid
Payload sample:
$ cat sample_payload
{
"resources": {
"profile": "custom",
"cpu": "50",
"memory": "50",
"disk": "100",
"devices": [{
"type": "serial",
"label": "HOST_DEV1",
"device-id": "/dev/ttyS1"
}],
"network": [{
"interface-name": "eth0",
"network-name": "iox-nat0",
"port_map": {
"mode": "auto",
"tcp": {
"9000": "15000",
"10100-10200": "20100-20200"
},
"udp": {
"19000": "25000"
}
}
}]
}
}
Running the command:
$ ioxclient application run nettest package.tar --payload sample_payload
Currently active profile : default
Command Name: application-run
Installation Successful. App is available at : https://127.0.0.1:8443/iox/api/v2/hosting/apps/nettest
Successfully deployed
Payload file : sample_payload. Will pass it as application/json in request body..
App nettest is Activated
App nettest is Started