This is a complete example :
// instanciate the client
const client = new OpenStackClient("https://auth.cloud.ovh.net/v3");
// authenticate the user
client.authenticate("user", "password");
// retrieve the available regions for the 'compute' service.
const regions = client.getRegions("compute")
// Get the available images for a region
const images = await client.getImages(regions[0].region_id);
// Get the available 'compute' flavor for a region
const flavors = await client.getComputeFlavors(regions[0].region_id)
// Create a server
const server = await client.createComputeServer( regions[0].region_id, "my-new-server-name", images[0].id, flavors[0].id );
...
On createComputeServer
you can add at the end of the method’s params,
an objet that match the following optional params : https://docs.openstack.org/api-ref/compute/?expanded=create-server-detail#id11
For example, it can be useful to upload a bash script that will be executed once the server is launched :
const script = "echo 'test'"
const server = await client.createComputeServer( regions[0].region_id, "my-new-server-name", images[0].id, flavors[0].id, {user_data: btoa(script)} );
To run them you must have those environment variables `:
# FOR UNIT TEST
export OPENSTACK_USER="XXX"
export OPENSTACK_PASSWORD="YYYYY"
export OPENSTACK_DOMAIN="Default"
export OPENSTACK_PROJECT="ZZZZZ"
export OPENSTACK_URL="https://auth.vexxhost.net/v3"
export OPENSTACK_REGION="sjc1"
export OPENSTACK_IMAGE="Debian GNU/Linux 10 (buster) [2019-12-02]"
export OPENSTACK_FLAVOR="v2-standard-1"
# FOR FULL DEPLOY
export OPENSTACK_SSHKEY_NAME="my-ssh-key";
export OPENSTACK_SSHKEY_PUB=$(cat ~/.ssh/id_rsa.pub)
There is two kind of tests :
-
paid : You can run them with the command
npm run test:paid
. Those tests spawn some servers, so they are not free of charge. -
free : You can run them with the command
npm run test:unit
.
Note
|
The command npm test run all tests (free & paid).
|
Note
|
You can use the paid test to deploy a server, just comment the after method
|
Important
|
Unit test fails on network for OVH |
Hyphe configuration is a parameter of the method hypheDeploy
.
The configuration must be a map of strings.
Exemple :
{
"HYPHE_MAXDEPTH": "4",
"HYPHE_DOWNLOAD_DELAY": "2",
"HYPHE_MAX_SIM_REQ": "13",
"HYPHE_HOST_MAX_SIM_REQ": "2",
"HYPHE_PROXY_PORT": "1",
"HYPHE_STORE_CRAWLED_HTML": "true",
"HYPHE_TRAPH_KEEPALIVE": "1801",
"HYPHE_TRAPH_MAX_SIM_PAGES": "251",
"HYPHE_OPEN_CORS_API": "true",
"HYPHE_DEFAULT_STARTPAGES_MODE": "[\"homepage\",\"pages-6\"]",
"HYPHE_CREATION_RULES": "{\"twitter.com\":\"path-1\"}"
}
Note
|
All those parameters are set in the files config-*.env .
|
If you want o deploy hyphe with the text indexation feature,
you need to add the following parameter in the config : "COMPOSE_FILE"="docker-compose.yml:docker-compose-text_indexation.yml"
The COMPOSE_FILE
is set as a global variable on the server, so docker will launch the adequate docker compose files
(see https://docs.docker.com/compose/reference/envvars/#compose_file)
-
Documentation : https://developer.openstack.org/
-
OVH API endpoint : https://auth.cloud.ovh.net/v3/
-
It’s a public cloud service, so every servers are available on internet.
-
We don’t need to have a project
STATUS: [OK]
-
Flavors doesn’t include storage, we need to create one.
-
Need to change the rules on the security group to allow HTTP, HTTPS & SSH from anywhere
STATUS: [OK]
All the network layout have to be done before to create a server. For example, per defaut a server has no network interface, except if a network is already present.
So we need to :
-
Create a network in the interface (it create the subnet + router …)
-
Create the server
-
Assign a floating IP address to server
STATUS: [OK] (but need some manual actions on the interface)