2. Outline
● About API, SDK, REST
● SmartDataCenter CloudAPI
○ Connect CloudAPI
○ Machine managements
○ Machine create options
○ Cloud Analysis
● After Class
○ Create a machine with pre-install joomla
○ Give your machine a domain
3. API and SDK
● Application Programming Interface
○ Is a set of routines, protocols, and tools for
building software applications
● Software Development Kit
○ Is typically a set of software development tools
System code
non-standard language API
SDKSpecific programming language
6. CloudAPI
● We can use cloudapi to ….
○ Provision new machines (both SmartMachines and
traditional Virtual Machines)
○ Manage your account credentials
○ Create custom analytics for monitoring your
inferastructure
7. Connect CloudAPI - curl
● curl: linux/unix command to view http(s)
requests
● REST API - curl
○ curl -sS -k
-H 'Accept:application/json'
-H 'x-Api-version:~6.5'
-u 'account:password' https://api.micloud.
tw/charles/machines
-X GET
Data input use JSON
Sepcify the API version
Sepcify the username
and password info
API route for action
API route method
8. Connect CloudAPI -
Command Line Interface(CLI)
● Command line interface(CLI) - node.js SDK
○ Install node.js
○ Install smartdc: npm install smartdc -g
○ Upload your ssh key to key store and set env value
CloudAPI Version 6.5.x
9. Connect CloudAPI - Java SDK
● Provider: Muzee (http://www.muzee.net/)
● Github: https://github.com/qrtt1/joyent.
cloudapi
● Piece of code:
SmartDCClient client =
new SmartDCClient(
":api-server:",
":user-account:",
":key-name:",
new File(":private-key:"));
Systme.out.println(client.listDatasets());
13. Import Key to Key Store -
The REST way / Use curl
● CreateKey (POST /:login/keys)
● curl -sS -k -H 'Accept:application/json'
https://api.micloud.tw/$account/keys -X POST
-H 'x-Api-version:~6.5'
-u '$account:$password'
-F 'key=<$publickeyPATH'
-F 'name=$keyname’
Use your credential
Use your key path
Give key a name
PS: We will skip “-H 'x-Api-version:~6.5' -u '$account:$password'“ in the following slides,
and the “https://api.micloud.tw” will skip, too.
In this example, the api will be: [POST] /:login/keys, and will have parameters “key” and
“name” need to provide.
14. Import Key to Key Store - Use CLI
● smartdc ~6.5
Use CLI command: sdc-setup
select “no” to import new key
select you key file path
do export like this...
15. ● ListKeys (GET /:login/keys)
● $ curl -sS -k -H 'Accept:application/json'
-H 'x-Api-version:~6.5'
-u $AUTH https://api.micloud.tw/charles/keys -X GET
Check your Key Store - curl
17. We assump user use Java & Node.js SDK already import key...
18. ● Account
● Regist Credit Card
● SSH Key
● Dataset:
The machine type, include OS or a
service preloaded system
● Package:
The size information of a machine,
include CPU, memory, disk size...
● Alias/Name:
The name of your machine
Before create machine
19. List the public dataset & packages
● $ sdc-listdatasets
ListDatasets (GET /:login/datasets)
● $ sdc-listpackages
ListPackages (GET /:login/packages)
● Tips:
○ use help to see more parameters
ex: sdc-listdatasets --help
○ check the document for more help
28. Advance Use of CloudAPI -
Create a Machine with User-Script
sdc-createmachine
--dataset "sdc:sdc:smartosplus64:3.0.7"
--package "XS 512MB RAM (4CORE)"
--script ./install.sh
--tag hadoop-namenode=me
curl -k https://raw.github.
com/peihsinsu/installer/master/smartos-
standard64/install-joomla.sh | sh
The Script: ./install.sh
Specify a script file to let machine
execute after boot