1 00:00:05,07 ---> 00:00:18,03
The SCADAPack 47xi Remote Smart RTU and Controller with Integrated Edge Platform is the latest
model in the SCADAPack x70 series, combining wide-ranging RTU capabilities with the flexibility
of Linux.
2 00:00:20,17 ---> 00:00:27,15
This video builds on the foundation information contained in the "SCADAPack 47xi: General
Docker Overview video.
3 00:00:30,15 ---> 00:00:38,29
This video shows how to use the SDK to prepare Docker container images for deployment to
SCADAPacks that do not have access to the internet.
4 00:00:40,09 ---> 00:00:48,10
It also demonstrates how to use service files to automatically start a Docker container
with Ubuntu when the SCADAPack boots to run services.
5 00:00:49,09 ---> 00:00:56,21
Finally, this video will describe how to exchange data between the SCADAPack Object Database
and an application within the container.
6 00:00:59,03 ---> 00:01:07,13
You will find in the accompanying application note prerequisites that include setting up
your SCADAPack, the SDK, and creating a workspace.
7 00:01:08,05 ---> 00:01:13,03
Our SDK already has a workspace, but we shall create a new workspace for this demonstration.
8 00:01:14,11 ---> 00:01:20,14
The instructions to do this can be found by searching RemoteConnect help for the phrase
"Multiple Workspaces".
9 00:01:21,16 ---> 00:01:24,15
The workspace needs to be mounted in order to be used.
10 00:01:25,19 ---> 00:01:28,06
This happens automatically when opening Eclipse.
11 00:01:30,08 ---> 00:01:35,29
This can also be done manually with the command displayed to the right, to make a new workspace
named "Ubuntu2"
12 00:01:39,04 ---> 00:01:44,22
After running the script, we hit "Y" to confirm that we want to create the missing directories.
13 00:01:45,14 ---> 00:01:48,22
You will notice in the file browser that we can see the mounted overlay.
14 00:01:49,15 ---> 00:01:54,06
These files reflect what will exist on the SCADAPack after this overlay has been applied.
15 00:01:55,04 ---> 00:02:00,17
Next, we shall copy the script to the root directory of the SDK VM, or Virtual Machine.
16 00:02:00,27 ---> 00:02:04,24
I'm running the SDK on a second computer so I'm going to use Filezilla.
17 00:02:05,08 ---> 00:02:12,00
If you are running the SDK inside a VMWare Virtual machine, you can simply drag the script
to the VM's desktop.
18 00:02:14,12 ---> 00:02:18,01
Now that the script has been copied, we give it executable permissions.
19 00:02:18,07 ---> 00:02:21,10
We can do this with Linux's "change mode" command.
20 00:02:22,26 ---> 00:02:29,09
In Linux, after typing the first letters of a filename, we shall hit the tab key to autocomplete
the rest of the letters.
21 00:02:30,11 ---> 00:02:31,16
Now we run the script.
22 00:02:32,00 ---> 00:02:35,19
We use "sudo" to run the script with elevated privileges.
23 00:02:36,05 ---> 00:02:39.26
We use "./" to specify that the script is in the current directory.
24 00:02:40,20 ---> 00:02:44,04
It is telling us that it has detected that the overlay has been mounted.
25 00:02:45,07 ---> 00:02:46,20
We hit "Y" to confirm
26 00:02:48,22 ---> 00:02:53,09
The script is telling us that it has a cached docker image from the last time it ran.
27 00:02:54,06 ---> 00:02:56,25
It is asking if I want to use the cached image.
28 00:02:57,17 ---> 00:02:59,20
I'm going to hit "Y" to make the image again.
29 00:03:05,25 ---> 00:03:09,19
Let s see a few things about what is inside this script and what it s doing.
30 00:03:10,08 ---> 00:03:12,29
The code highlighted here is what is called a Dockerfile.
31 00:03:14,17 ---> 00:03:17,24
A dockerfile is a way to automate the creation of a container.
32 00:03:18,24 ---> 00:03:23,29
Dockerfiles can be executed directly on the SCADAPack or in the SDK with a script like
we see here.
33 00:03:24,29 ---> 00:03:30,20
The docker file pulls the Ubuntu image from Docker Hub then it executes these commands
inside the container.
34 00:03:31,11 ---> 00:03:39,05
This script uses a "HereDoc" to push the Dockerfile to /TempDir/Dockerfile.
35 00:03:40,03 ---> 00:03:46,28
The script then uses the "buildx" command which uses QEMU to make a cross-platform image.
36 00:03:47,15 ---> 00:03:55,11
This is done because the PC being used has an x86 architecture CPU but the SCADAPack
has an ARM architecture CPU.
37 00:03:56,12 ---> 00:04:02,16
This script also adds DNS servers to the overlay filesystem's "resolv.conf" file.
38 00:04:04,12 ---> 00:04:06,18
The script creates a couple service files.
39 00:04:06,24 ---> 00:04:10,19
A service file is like a DOS "autoexec.bat" file.
40 00:04:11,10 ---> 00:04:16,23
This "UbuntuPython.service" starts the Ubuntu container when the SCADAPack boots.
41 00:04:18,00 ---> 00:04:23,16
We also create a dependent service file that runs after "UbuntuPython.service" starts
42 00:04:24,20 ---> 00:04:33,20
This service runs a script named "usr/bin/ApacheStart" that will be present on the SCADAPack host
when the overlay has been applied.
43 00:04:35,13 ---> 00:04:41,07
The key thing this script does is to run a docker "exec" command to start Apache webserver
inside the container.
44 00:04:42,10 ---> 00:04:45,22
After the Apache webserver has started it runs a Python script.
45 00:04:46,07 ---> 00:04:48,29
If the script runs forever it just stays here.
46 00:04:49,17 ---> 00:04:54,28
If the script runs then exits, it uses a loop so that the script will be executed every
5 seconds.
47 00:04:56,16 ---> 00:05:03,26
In the terminal window on the left we see that after the script stops running, it says
that Step 1 is to use Eclipse to Package the Bundle
48 00:05:05,07 ---> 00:05:07,06
To do this, we must start Eclipse.
49 00:05:08,00 ---> 00:05:12,22
You can find how to do this by searching RemoteConnect help for "Starting Eclipse".
50 00:05:13,07 ---> 00:05:19,09
After clicking the "Starting Eclipse article, if you click the "Contents" tab you will see
the related SDK articles.
51 00:05:19,26 ---> 00:05:22,12
Eclipse asks what workspace we want to use.
52 00:05:22,22 ---> 00:05:26,02
We choose the workspace named "Ubuntu2" that we just created.
53 00:05:28,06 ---> 00:05:32,00
Eclipse will now have a plugin for creating new SCADAPack projects.
54 00:05:33,20 ---> 00:05:35,22
We re going to create the new project manually.
55 00:05:48,13 ---> 00:05:54,04
Once the project is created, we can expand the tree in the project explorer to see several
build targets.
56 00:05:54,16 ---> 00:05:59,14
We re going to run the "Package" build target, but we will see that the system has detected
an error.
57 00:06:00,14 ---> 00:06:07,24
The reason this error has been detected is because we created a new workspace, but we
have not yet generated a security key for the new workspace.
58 00:06:07,29 ---> 00:06:16,22
Since this SCADAPack is already setup to accept bundles from the key in the old workspace,
we shall instead copy the key from the old workspace to the new workspace.
59 00:06:16,27 ---> 00:06:19,20
To setup a key, see the RemoteConnect documentation.
60 00:06:20,19 ---> 00:06:23,22
This is the folder that has the keys from the first workspace.
61 00:06:24,26 ---> 00:06:30,21
We open a new window then navigate to the new workspace and copy the keys from the old
workspace to the new workspace.
62 00:06:43,05 ---> 00:06:47,01
We re-run the Package build target and this time it should succeed.
63 00:06:48,10 ---> 00:06:56,02
Step 3B of the instructions from the script says to copy the "rauc" bundle to the "/tmp"
directory on the SCADAPack.
64 00:07:00,22 ---> 00:07:06,09
We re going to launch Filezilla and connect it to the SCADAPack via the SFTP SSH protocol.
65 00:07:07,16 ---> 00:07:11,07
When it asks me if we accept the SCADAPack's signature, we click "Yes".
66 00:07:14,05 ---> 00:07:20,03
We shall now copy the integrator bundle "rauc" file to the "/tmp" directory on the SCADAPack.
67 00:07:30,06 ---> 00:07:35,17
While the "rauc" bundle is copying, we can now delete a previous Ubuntu container from
the SCADAPack.
68 00:07:35,27 ---> 00:07:38,18
This was the container we manually made in the previous video.
69 00:07:39,21 ---> 00:07:44,19
We'll type "docker container ls-a" to see all running and stopped containers.
70 00:07:45,22 ---> 00:07:48,05
We can see that the previous container is named "Ubuntu".
71 00:07:49,04 ---> 00:07:52,00
Since it is already stopped, we don't need to stop it.
72 00:07:53,13 ---> 00:07:57,02
We can type "docker rm Ubuntu" to delete the container.
73 00:08:00,18 ---> 00:08:05,16
Now when we check again, we can see that we no longer have any containers on the SCADAPack.
74 00:08:13,06 ---> 00:08:21,21
Now that the "rauc" file has been copied to the "tmp" directory, we can type "rauc install"
on the file then we reboot the SCADAPack.
75 00:08:34,22 ---> 00:08:38,11
Once the SCADAPack responds to our ping, we shall log into it again with Putty.
76 00:08:48,07 ---> 00:08:52,14
The first SSH session following a SCADAPack restart takes about a minute.
77 00:08:57,04 ---> 00:08:58,16
We'll click Y at the prompt.
78 00:09:00,02 ---> 00:09:06,13
In step 9, the script says to run the "UbuntuPythonFinalize.sh" script on the SCADAPack.
79 00:09:08,00 ---> 00:09:10,04
We can see this script is present on the SCADAPack.
80 00:09:13,05 ---> 00:09:17,28
We can also see a tarball image of the docker container that will be loaded by the script.
81 00:09:22,20 ---> 00:09:25,24
We have already showed you what was under the hood of these service files.
82 00:09:27,03 ---> 00:09:28,15
This is where they are documented.
83 00:09:30,01 ---> 00:09:33,07
Right here is a description of the "apache2.service" file.
84 00:09:33,28 ---> 00:09:37,19
The Ubuntu python service starts the Ubuntu container at boot.
85 00:09:38,07 ---> 00:09:42,17
The command shown here in green can run anytime to get a command prompt inside the container.
86 00:09:42,27 ---> 00:09:48,17
From this command prompt you can do things such as using "PIP" to install additional
Python libraries.
87 00:09:49,26 ---> 00:09:54,29
These are system "d" services and are controlled with the "systemctl" command.
88 00:09:55,20 ---> 00:09:59,20
You can start and stop them immediately at any time with the start and stop commands.
89 00:10:00,08 ---> 00:10:05,09
You can enable or disable whether the container starts or does not start automatically at
boot.
90 00:10:06,26 ---> 00:10:12,07
You can execute python scripts from the SCADAPack host or from inside the container with the
syntax shown here.
91 00:10:14,03 ---> 00:10:18,15
All objects in the RTU are accessible through the Edge board's Redis database.
92 00:10:20,15 ---> 00:10:32,05
This script uses the Linux SED command to modify the Redis configuration such that it
listens on the Docker interface which has the IP address 10.10.0.1.
93 00:10:34,22 ---> 00:10:37,29
We see when the script imports the container, it does a couple things.
94 00:10:39,11 ---> 00:10:44,00
It forwards port 8080 on the host system to port 80 inside the container.
95 00:10:45,14 ---> 00:10:54,24
It also maps "/mnt/secdata/redis" on the host to the container's "/mnt" folder.
96 00:10:56,08 ---> 00:11:01,26
The data found in this folder is needed by any program wishing to read or write to the
Redis database.
97 00:11:03,25 ---> 00:11:08,18
Now that the script is done, we want to check the status of the services the script has
created.
98 00:11:10,03 ---> 00:11:15,00
Since "UbuntuPython.service" is running, we know the Ubuntu container is also running.
99 00:11:18,16 ---> 00:11:23,20
Let s check the status of my "apache2.service" to see if Apache is running inside the container.
100 00:11:24,18 ---> 00:11:26,02
And we see it is running.
101 00:11:27,15 ---> 00:11:31,18
We enter the "IP address:80" in the web browser, and we can confirm this.
102 00:11:33,19 ---> 00:11:38,08
The instruction tells us to type the "SCADAPack IP: 8080/hello world".
103 00:11:40:12 ---> 00:11:43,22
When we do this we see the output of the hello world python script.
104 00:11:48,00 ---> 00:11:53,27
The application note also has instructions on how to use the Notepad++ NppFTP plugin.
105 00:11:55,24 ---> 00:12:04,27
One way to develop Python scripts on the SCADAPack is to edit them from Notepad++ in one window
while executing them via a Putty SSH session in a separate window.
106 00:12:09,07 ---> 00:12:16,00
This Ubuntu Python application note was developed to give an example of how to deploy containers
to the SCADAPack 47xi.
107 00:12:17,20 ---> 00:12:20,23
The list of deployable container types is virtually endless.
108 00:12:22,13 ---> 00:12:29,11
This application note configures Redis to listen on the docker interface and also shows
how to pass the Redis login key to the container.
109 00:12:31,14 ---> 00:12:37,10
Please see the application note for more information on how to access the Redis database from inside
docker containers.