This will walk you through the steps required to deploy a VM using the MeX console.
One slightly confusing bit is that we do refer to the VM as an Application within our interface and within the api calls. For our purposes, you can think of the VM as just one type of application that we can deploy.
wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2curl -O https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2ls CentOS-7-x86_64-GenericCloud.qcow2curl -u <username> -T ./CentOS-7-x86_64-GenericCloud.qcow2 "https://artifactory.mobiledgex.net/artifactory/repo-<orgname>/CentOS-7-x86_64-GenericCloud.qcow2"
$ curl -q -u demo -T ./CentOS-7-x86_64-GenericCloud.qcow2 "https://artifactory.mobiledgex.net/artifactory/repo-demoorg/CentOS-7-x86_64-GenericCloud.qcow2" --progress
Enter host password for user 'demo':
{
"repo" : "repo-demoorg",
"path" : "/CentOS-7-x86_64-GenericCloud.qcow2",
"created" : "2020-04-09T14:23:27.958Z",
"createdBy" : "demo",
"downloadUri" : "https://artifactory.mobiledgex.net/artifactory/repo-demoorg/CentOS-7-x86_64-GenericCloud.qcow2",
"mimeType" : "application/octet-stream",
"size" : "941359104",
"checksums" : {
"sha1" : "0a60d34921a5e922aeacfeece13bd5ccfb024cb3",
"md5" : "ec8c38b1656ded3e03a6dc0938e201f1",
"sha256" : "b376afdc0150601f15e53516327d9832216e01a300fecfc302066e36e2ac2b39"
},
"originalChecksums" : {
"sha256" : "b376afdc0150601f15e53516327d9832216e01a300fecfc302066e36e2ac2b39"
},
"uri" : "https://artifactory.mobiledgex.net/artifactory/repo-demoorg/CentOS-7-x86_64-GenericCloud.qcow2"
}%
Request
$ curl -s -XPOST https://console.mobiledgex.net/api/v1/login \
-H "Content-Type: application/json" \
-d '{ "password": "somepass", "username": "demo" }'
Response
{"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1ODYyOTcxNTMsImlhdCI6MTU4NjIxMDc1MywidXNlcm5hbWUiOiJkZW1vIiwiZW1haWwiOiJkZW1vQG1vYmlsZWRnZXguY29tIiwia2lkIjoyfQ.bAqdwNw2stM0r24nrbu08c7qbZjraOGoTLVCopYvsIoX1uxKoEeOm8i78ihp8Tze9gKxttLTx76hKYS6tKo0sA"}
All subsequent calls are shown with two assumptions:
https://console.mobiledgex.net/api/v1.curlrc file setup with the following values:
-H "Content-Type: application/json"-H "Authorization: Bearer <JWT Token>"For 2xx responses, the body of the response will be printed to stdout. For all other responses the body will be dumped to stderr.
Request
POST /auth/ctrl/CreateApp < payload.json
payload.json
{
"Region": "EU",
"App": {
"key": {
"developer_key": {
"name": "demoorg"
},
"name": "vmtwo",
"organization": "demoorg",
"version": "1.0"
},
"deployment": "vm",
"access_type": 0,
"image_path": " https://artifactory.mobiledgex.net/artifactory/repo-demoorg/CentOS-7-x86_64-GenericCloud.qcow2#md5:ec8c38b1656ded3e03a6dc0938e201f1",
"image_type": 1,
"internal_ports": true,
"default_flavor": {
"name": "m4.small"
},
"revision": 0,
"access_ports": "TCP:22",
"deployment_manifest": " #cloud-config\r\n user: demouser\r\n password: NoMoreSecret3\r\n chpasswd: {expire: False}\r\n ssh_pwauth: True"
}
}
Response
{}
Notes:
deployment_manifest field only accepts a cloud_init file.cloud_init file needs to have #cloud-config at the beginning of the data.cloud_init file needs to be appropriately escaped in order to conform with json standards. If you need help with this, [freeformatter.com}(https://v,)]Request
POST /auth/ctrl/CreateAppInst < payload.json
payload.json
{
"Region": "EU",
"AppInst": {
"key": {
"app_key": {
"organization": "demoorg",
"name": "vmtwo",
"version": "1.0",
"developer_key": {
"name": "demoorg"
}
},
"cluster_inst_key": {
"cluster_key": {
"name": "DefaultVMCluster"
},
"cloudlet_key": {
"operator_key": {
"name": "TDG"
},
"name": "munich-main"
},
"developer": "demoorg"
}
},
"flavor": {
"name": "m4.small"
}
}
}
Response
{"data":{"message":"Creating"}}
{"data":{"message":"Creating VM Image from URL"}}
{"data":{"message":"Deploying VM"}}
{"data":{"message":"Creating Heat Stack for demoorgvmtwo10"}}
{"data":{"message":"Creating Heat Stack for demoorgvmtwo10, Heat Stack Status: CREATE_IN_PROGRESS"}}
{"data":{"message":"Creating Heat Stack for demoorgvmtwo10, Heat Stack Status: CREATE_COMPLETE"}}
{"data":{"message":"Ready"}}
{"data":{"message":"Created AppInst successfully"}}
Get FQDN and Port; payload content is used to filter.
Request
POST api/v1/auth/ctrl/ShowAppInst < payload.json | json -Hag data.uri
Response
demoorgvmtwo10.munich-main.tdg.mobiledgex.net [
{
"proto": 1,
"internal_port": 22,
"public_port": 22
}
]
Now you can ssh into the system (provided the system is running an ssh server and accepting connections on that port)