In this tutorial, we will show you how to launch multiple Scalable Compute nodes using the Neocortix Cloud Services Script Interface. From the previous tutorial, you should already have been able to launch a single Scalable Compute node using the Web Interface.
Most of this tutorial will be done using command lines in a Linux shell window. If you are using a Windows machine, you can use git-bash as your shell window, as shown below. You will need to have Python and Git installed on your machine, as shown below.
(Note that on many Linux machines, you may need to use the command python3 instead of python.)
In the next step, we will be downloading the ncs.py Python script from our git repository at https://github.com/neocortix/ncscli.git. First, cd to the directory to which you would like to download the code. In the example below, we have chosen the C:/ drive on a Windows machine, with the command
Then, to download the code, we issued the command
git clone https://github.com/neocortix/ncscli.git
Now you will go down into the ncscli/ncscli directory, by issuing the
command, as shown below. Listing the contents of the directory with the ls command reveals the ncs.py program in that directory. You will be using the ncs.py script to launch your Scalable Compute nodes.
But first you will need to get your Authorization Token, which will allow our system to identify who is running the script. To get your Authorization Token (authToken), first go to the Neocortix Cloud Services page, at https://cloud.neocortix.com. Login with your username and password if necessary, and then you should see the Dashboard page (below). Click on the "Profile" card, as shown in Red:
This will take you to the Profile page (below). Click on the Gear button, as shown in Red, and then click on the "API Access" pull-down menu item, as shown in Green:
By default, your API Access is disabled. To enable your API Access, click on the slider switch, as shown in Red.
Now your Authorization Token, (also called API Token or authToken) is revealed - a long random string of letters and numbers. You can copy it to the clipboard by clicking on the Copy icon, as shown in Red:
Now you have everything you need to launch multiple nodes using the ncs.py script. On this first try, we will just launch 2 nodes. Go back to your shell window, and enter the following command line:
python ncs.py sc launch --authToken PasteYourAuthTokenHere --count 2 --showPasswords --json
as shown outlined in Red, below:
(Again, note that on many Linux machines, you may need to use the command python3 instead of python.)
The system will start to generate diagnostic messages as it launches your two nodes. Typically, it will take a couple of minutes for both nodes to complete their launch. When it is finished, you will see the "Created 2 Instances" message, as shown in Blue above. And the last two long lines outlined in Green are the returned properties of your instances, such as port, user name, password, and instance ID, as you have already seen in the previous tutorial using the Web Interface.
Congratulations, you have just launched 2 Scalable Compute nodes using the Script method! And of course, we call this "Scalable Compute", because with this method, you can launch a huge number of nodes this way.
Finally, you can check on the status of your two running instances, using the "list" command:
python ncs.py sc list --authToken PasteYourAuthTokenHere
And you can terminate your two running instances, using the "terminate" command twice:
python ncs.py sc terminate --authToken PasteYourAuthTokenHere --instanceID PasteYourInstanceID1Here
python ncs.py sc terminate --authToken PasteYourAuthTokenHere --instanceID PasteYourInstanceID2Here
Here, we show a "list" command (in Red, below), to verify that we have two running instances, and to get their instanceIDs. Then we show two "terminate" commands (in Green, below) to terminate the two instances using their instanceIDs. And then finally, we show another "list" command (in Blue below), to verify that the instances are no longer running.
Congratulations! You have launched two Scalable Compute Nodes, verified that they are running, terminated them, and verified that they are terminated, all using the ncs.py Script Interface!
In the next Tutorial, you will learn how to run a Locust Load Test using a single Scalable Compute Node.