added docs for tracking containers

This commit is contained in:
2021-07-18 13:11:41 +04:00
parent 489ffd6d0c
commit a416578702
5 changed files with 43 additions and 9 deletions

View File

@@ -1,10 +1,15 @@
# Client Module Implementation
This section focuses in depth on how the client module works. To understand the architecture of
the client module refer to section 4.2. The client module is incharge of communicating with
## Topics
1. [Updating the IP table](#updating-the-IP-table)
2. [Reading server specifications](#reading-server-specifications)
3. [Client creating and removing container](#Client-creating-and-removing-container)
4. [Tracking Containers](#Ttacking-Containers )
This section focuses in depth on how the client module works. The client module is incharge of communicating with
different servers based on the IP addresses provided to the user. The IP addresses are derived
from peer to peer modules. Section 5.6 talks more in depth regarding the peer to peer module.
The objective here is how the client module interacts with peer to peer module and server module.
from peer to peer modules. The objective here is how the client module interacts with peer to peer module
and server module.
### Updating the IP table
The client module calls the peer to peer module to get the local IP table initially, Based on the
@@ -31,4 +36,24 @@ the container ID, ports open , SSH username, SSH password, VNC username and VNC
At the moment the username and password are hard coded from the server side for both SSH and
VNC.
To remove a container the client module only requires the server IP address and the container ID.
The client prints the response from the server Rest api.
The client prints the response from the server Rest api.
### Tracking Containers
Clients create docker images in multiple machines. This means if the client (i.e user) has many
containers created there needs to be a way to track them. To track containers there is a file
called ```trackcontainers.json``` which tracks all the containers running. The snippet below
show a sample structure of file ```trackcontainer.json```.
```
{
"TrackContainer": [
{
"ID": "<ID>",
"Container": {<docker.DockerVM struct>},
"IpAddress": "<IP Address>"
}
]
}
```
The default path to the container tracker is ```client/trackcontainers/trackcontainers.json```.

View File

@@ -133,6 +133,12 @@ p2prc --ls
p2prc --ni
```
### Viewing Containers created Client side
```
p2prc --tc
```
[read more on tracking containers](ClientImplementation.md#tracking-containers)
<br>
--------------

View File

@@ -66,7 +66,7 @@ func AddTrackContainer(d *docker.DockerVM,ipAddress string) error {
trackContainers.TrackcontianerList = append(trackContainers.TrackcontianerList, trackContainer)
// write modified information to the tracked json file
data,err := json.Marshal(trackContainers)
data,err := json.MarshalIndent(trackContainers, "", "\t")
if err != nil {
return err
}
@@ -104,7 +104,7 @@ func RemoveTrackedContainer(id string) error {
trackedContianers.TrackcontianerList = append(trackedContianers.TrackcontianerList[:removeElement], trackedContianers.TrackcontianerList[removeElement+1:]...)
// write modified information to the tracked json file
data,err := json.Marshal(trackedContianers)
data,err := json.MarshalIndent(trackedContianers, "", "\t")
if err != nil {
return err
}

View File

@@ -80,6 +80,7 @@ func RemoveContianer(IP string,ID string) error {
return err
}
// Checks if success is returned in the body
if string(byteValue[:]) == "success" {
fmt.Println("success")
}
@@ -89,7 +90,7 @@ func RemoveContianer(IP string,ID string) error {
if err != nil {
return err
}
return nil
}

View File

@@ -1 +1,3 @@
{"TrackContainer":[]}
{
"TrackContainer": []
}