From a41657870279925694d0b91a74939470ebef1886 Mon Sep 17 00:00:00 2001 From: Akilan Selvacoumar Date: Sun, 18 Jul 2021 13:11:41 +0400 Subject: [PATCH] added docs for tracking containers --- Docs/ClientImplementation.md | 35 ++++++++++++++++++--- Docs/Installation.md | 6 ++++ client/TrackContainers.go | 4 +-- client/container.go | 3 +- client/trackcontainers/trackcontainers.json | 4 ++- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Docs/ClientImplementation.md b/Docs/ClientImplementation.md index af15b53..0ca0467 100644 --- a/Docs/ClientImplementation.md +++ b/Docs/ClientImplementation.md @@ -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. \ No newline at end of file +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": "", + "Container": {}, + "IpAddress": "" + } + ] +} +``` +The default path to the container tracker is ```client/trackcontainers/trackcontainers.json```. + diff --git a/Docs/Installation.md b/Docs/Installation.md index a4a6e2d..4aff042 100644 --- a/Docs/Installation.md +++ b/Docs/Installation.md @@ -133,6 +133,12 @@ p2prc --ls p2prc --ni ``` +### Viewing Containers created Client side +``` +p2prc --tc +``` +[read more on tracking containers](ClientImplementation.md#tracking-containers) +
-------------- diff --git a/client/TrackContainers.go b/client/TrackContainers.go index 2c6222f..8b5ef02 100644 --- a/client/TrackContainers.go +++ b/client/TrackContainers.go @@ -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 } diff --git a/client/container.go b/client/container.go index 4b4c113..3698854 100644 --- a/client/container.go +++ b/client/container.go @@ -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 } diff --git a/client/trackcontainers/trackcontainers.json b/client/trackcontainers/trackcontainers.json index 30d26af..08a05b5 100644 --- a/client/trackcontainers/trackcontainers.json +++ b/client/trackcontainers/trackcontainers.json @@ -1 +1,3 @@ -{"TrackContainer":[]} \ No newline at end of file +{ + "TrackContainer": [] +} \ No newline at end of file