Compare commits
5 Commits
python-add
...
untracked-
| Author | SHA1 | Date | |
|---|---|---|---|
| d2d1b5bc9f | |||
| 888ad8acb7 | |||
| e5d4381fd9 | |||
| c7be50d3b7 | |||
| 1c06d5b882 |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -11,13 +11,23 @@ config.json
|
||||
|
||||
#ignore generated iptables
|
||||
p2p/iptable/
|
||||
!p2p/iptable/.gitkeep
|
||||
#ignore plugins added
|
||||
plugin/deploy/
|
||||
!plugin/deploy/.gitkeep
|
||||
#ignore track container file
|
||||
client/trackcontainers/
|
||||
!client/trackcontainers/.gitkeep
|
||||
# Test generated files
|
||||
generate/p2prctest
|
||||
!generate/p2prctest/.gitkeep
|
||||
generate/Test
|
||||
!generate/Test/.gitkeep
|
||||
|
||||
#ignore windows exe files
|
||||
*.exe
|
||||
dist/
|
||||
|
||||
#MACOS .idea file
|
||||
.DS_Store
|
||||
.gitkeep
|
||||
|
||||
BIN
artwork/p2prc-logos/.DS_Store
vendored
BIN
artwork/p2prc-logos/.DS_Store
vendored
Binary file not shown.
@@ -3,7 +3,7 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/google/uuid"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -24,7 +24,7 @@ type Group struct {
|
||||
}
|
||||
|
||||
// CreateGroup Creates a new group to add a set of track containers
|
||||
func CreateGroup() (*Group, error){
|
||||
func CreateGroup() (*Group, error) {
|
||||
// Creating variable of type new group
|
||||
var NewGroup Group
|
||||
// Generate new UUID for group ID
|
||||
@@ -40,7 +40,7 @@ func CreateGroup() (*Group, error){
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &NewGroup,nil
|
||||
return &NewGroup, nil
|
||||
}
|
||||
|
||||
// RemoveGroup Removes group based on the group ID provided
|
||||
@@ -101,21 +101,21 @@ func AddContainerToGroup(ContainerID string, GroupID string) (*Group, error) {
|
||||
}
|
||||
|
||||
// RemoveContainerGroup Remove Container from the group ID specified
|
||||
func RemoveContainerGroup(ContainerID string, GroupID string) (*Group,error) {
|
||||
func RemoveContainerGroup(ContainerID string, GroupID string) (*Group, error) {
|
||||
// Get container information based on container ID provided
|
||||
containerInfo, err := GetContainerInformation(ContainerID)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
// Gets group information based on the group ID provided
|
||||
group, err := GetGroup(GroupID)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
// Remove container from the appropriate group
|
||||
err = group.RemoveContainerGroup(containerInfo)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
// Get Groups information from reading the grouptrackcontainer.json file
|
||||
groups, err := ReadGroup()
|
||||
@@ -163,7 +163,7 @@ func RemoveContainerGroups(ContainerID string) error {
|
||||
|
||||
// GetGroup Gets group information based on
|
||||
// group id provided
|
||||
func GetGroup(GroupID string) (*Group,error) {
|
||||
func GetGroup(GroupID string) (*Group, error) {
|
||||
// Read group information from the
|
||||
//grouptrackcontainer json file
|
||||
groups, err := ReadGroup()
|
||||
@@ -179,7 +179,7 @@ func GetGroup(GroupID string) (*Group,error) {
|
||||
}
|
||||
}
|
||||
|
||||
return nil,errors.New("Group not found. ")
|
||||
return nil, errors.New("Group not found. ")
|
||||
}
|
||||
|
||||
// AddGroupToFile Adds Group struct to the GroupTrackContainer File
|
||||
@@ -204,16 +204,16 @@ func (grp *Group) AddGroupToFile() error {
|
||||
|
||||
// ReadGroup Function reads grouptrackcontainers.json and converts
|
||||
// result to Groups
|
||||
func ReadGroup() (*Groups,error) {
|
||||
func ReadGroup() (*Groups, error) {
|
||||
// Get Path from config
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
jsonFile, err := os.Open(config.GroupTrackContainersPath)
|
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
// defer the closing of our jsonFile so that we can parse it later on
|
||||
defer jsonFile.Close()
|
||||
@@ -227,9 +227,8 @@ func ReadGroup() (*Groups,error) {
|
||||
return &groups, nil
|
||||
}
|
||||
|
||||
|
||||
// WriteGroup Function to write type Groups to the grouptrackcontainers.json file
|
||||
func (grp *Groups)WriteGroup() error {
|
||||
func (grp *Groups) WriteGroup() error {
|
||||
file, err := json.MarshalIndent(grp, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -248,13 +247,13 @@ func (grp *Groups)WriteGroup() error {
|
||||
}
|
||||
|
||||
// AddContainer Adds a container to the Tracked container list of the group
|
||||
func (grp *Group)AddContainer(Container *TrackContainer) error {
|
||||
func (grp *Group) AddContainer(Container *TrackContainer) error {
|
||||
grp.TrackContainerList = append(grp.TrackContainerList, Container)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveContainerGroup Removes container information from the group
|
||||
func (grp *Group)RemoveContainerGroup(Container *TrackContainer) error {
|
||||
func (grp *Group) RemoveContainerGroup(Container *TrackContainer) error {
|
||||
// Iterating through all container in the Group of Tracked Container
|
||||
for i, container := range grp.TrackContainerList {
|
||||
// If the container ID matches then remove the container from the group
|
||||
@@ -266,9 +265,9 @@ func (grp *Group)RemoveContainerGroup(Container *TrackContainer) error {
|
||||
}
|
||||
|
||||
// RemoveContainerGroups removes container found in all groups
|
||||
func (grp *Groups)RemoveContainerGroups(Container *TrackContainer) error {
|
||||
func (grp *Groups) RemoveContainerGroups(Container *TrackContainer) error {
|
||||
// Iterating through all groups
|
||||
for i,group := range grp.GroupList {
|
||||
for i, group := range grp.GroupList {
|
||||
// Removes the container in the following group
|
||||
// if it exists
|
||||
err := group.RemoveContainerGroup(Container)
|
||||
@@ -283,7 +282,7 @@ func (grp *Groups)RemoveContainerGroups(Container *TrackContainer) error {
|
||||
|
||||
// ModifyContainerGroups Modifies container information is all groups
|
||||
// available
|
||||
func (TC *TrackContainer)ModifyContainerGroups() error {
|
||||
func (TC *TrackContainer) ModifyContainerGroups() error {
|
||||
group, err := ReadGroup()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -293,7 +292,7 @@ func (TC *TrackContainer)ModifyContainerGroups() error {
|
||||
// ID matches
|
||||
for i, _ := range group.GroupList {
|
||||
// Checking in each group if the modified container ID exists
|
||||
for j, _:= range group.GroupList[i].TrackContainerList {
|
||||
for j, _ := range group.GroupList[i].TrackContainerList {
|
||||
// If there is match then change them
|
||||
if group.GroupList[i].TrackContainerList[j].Id == TC.Id {
|
||||
group.GroupList[i].TrackContainerList[j] = TC
|
||||
|
||||
@@ -2,7 +2,7 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -46,14 +46,14 @@ func TestAddContainerToGroup(t *testing.T) {
|
||||
|
||||
// Creating and adding the container to the
|
||||
// tracked list
|
||||
container1 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Testing the AddTrackContainer Function and adding the first container created
|
||||
err = AddTrackContainer(container1,"0.0.0.0")
|
||||
err = AddTrackContainer(container1, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container1.ID)
|
||||
@@ -66,7 +66,7 @@ func TestAddContainerToGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
// Adds container information to the group
|
||||
Group, err := AddContainerToGroup(container1.ID,group.ID)
|
||||
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
@@ -109,14 +109,14 @@ func TestGroup_RemoveContainerGroup(t *testing.T) {
|
||||
|
||||
// Creating and adding the container to the
|
||||
// tracked list
|
||||
container1 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Testing the AddTrackContainer Function and adding the first container created
|
||||
err = AddTrackContainer(container1,"0.0.0.0")
|
||||
err = AddTrackContainer(container1, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container1.ID)
|
||||
@@ -129,7 +129,7 @@ func TestGroup_RemoveContainerGroup(t *testing.T) {
|
||||
}
|
||||
|
||||
// Adds container information to the group
|
||||
Group, err := AddContainerToGroup(container1.ID,group.ID)
|
||||
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
@@ -138,7 +138,7 @@ func TestGroup_RemoveContainerGroup(t *testing.T) {
|
||||
PrettyPrint(Group)
|
||||
|
||||
// Removing docker container from the group
|
||||
Group, err = RemoveContainerGroup(container1.ID,group.ID)
|
||||
Group, err = RemoveContainerGroup(container1.ID, group.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
@@ -191,14 +191,14 @@ func TestGroups_RemoveContainerGroups(t *testing.T) {
|
||||
|
||||
// Creating and adding the container to the
|
||||
// tracked list
|
||||
container1 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Testing the AddTrackContainer Function and adding the first container created
|
||||
err = AddTrackContainer(container1,"0.0.0.0")
|
||||
err = AddTrackContainer(container1, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container1.ID)
|
||||
@@ -211,7 +211,7 @@ func TestGroups_RemoveContainerGroups(t *testing.T) {
|
||||
}
|
||||
|
||||
// Adds container information to the group
|
||||
Group, err := AddContainerToGroup(container1.ID,group.ID)
|
||||
Group, err := AddContainerToGroup(container1.ID, group.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
@@ -220,7 +220,7 @@ func TestGroups_RemoveContainerGroups(t *testing.T) {
|
||||
PrettyPrint(Group)
|
||||
|
||||
// Adds container information to the group
|
||||
Group1, err := AddContainerToGroup(container1.ID,group1.ID)
|
||||
Group1, err := AddContainerToGroup(container1.ID, group1.ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
|
||||
@@ -3,7 +3,7 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
@@ -23,13 +23,13 @@ type TrackContainer struct {
|
||||
}
|
||||
|
||||
// AddTrackContainer Adds new container which has been added to the track container
|
||||
func AddTrackContainer(d *docker.DockerVM,ipAddress string) error {
|
||||
func AddTrackContainer(d *docker.DockerVM, ipAddress string) error {
|
||||
// Checking if pointer d is null
|
||||
if d == nil {
|
||||
return errors.New("d is nil")
|
||||
}
|
||||
//Get config information to derive paths for track containers json file
|
||||
config,err := config.ConfigInit()
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -66,11 +66,11 @@ func AddTrackContainer(d *docker.DockerVM,ipAddress string) error {
|
||||
trackContainers.TrackContainerList = append(trackContainers.TrackContainerList, trackContainer)
|
||||
|
||||
// write modified information to the tracked json file
|
||||
data,err := json.MarshalIndent(trackContainers, "", "\t")
|
||||
data, err := json.MarshalIndent(trackContainers, "", "\t")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(config.TrackContainersPath,data,0777)
|
||||
err = ioutil.WriteFile(config.TrackContainersPath, data, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func AddTrackContainer(d *docker.DockerVM,ipAddress string) error {
|
||||
// RemoveTrackedContainer This function removos tracked container from the trackcontainer JSON file
|
||||
func RemoveTrackedContainer(id string) error {
|
||||
//Get config information to derive paths for track containers json file
|
||||
config,err := config.ConfigInit()
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,11 +104,11 @@ func RemoveTrackedContainer(id string) error {
|
||||
trackedContainers.TrackContainerList = append(trackedContainers.TrackContainerList[:removeElement], trackedContainers.TrackContainerList[removeElement+1:]...)
|
||||
|
||||
// write modified information to the tracked json file
|
||||
data,err := json.MarshalIndent(trackedContainers, "", "\t")
|
||||
data, err := json.MarshalIndent(trackedContainers, "", "\t")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(config.TrackContainersPath,data,0777)
|
||||
err = ioutil.WriteFile(config.TrackContainersPath, data, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -117,17 +117,17 @@ func RemoveTrackedContainer(id string) error {
|
||||
}
|
||||
|
||||
// ViewTrackedContainers View Containers currently tracked
|
||||
func ViewTrackedContainers() (error,*TrackContainers) {
|
||||
config,err := config.ConfigInit()
|
||||
func ViewTrackedContainers() (error, *TrackContainers) {
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return err,nil
|
||||
return err, nil
|
||||
}
|
||||
trackedContianers, err := ReadTrackContainers(config.TrackContainersPath)
|
||||
if err != nil {
|
||||
return err,nil
|
||||
return err, nil
|
||||
}
|
||||
|
||||
return nil,trackedContianers
|
||||
return nil, trackedContianers
|
||||
}
|
||||
|
||||
// ReadTrackContainers Reads containers which are currently tracked
|
||||
@@ -167,7 +167,7 @@ func GetContainerInformation(ID string) (*TrackContainer, error) {
|
||||
}
|
||||
|
||||
// ModifyContainerInformation Modifies information inside the container
|
||||
func (TC *TrackContainer)ModifyContainerInformation() error {
|
||||
func (TC *TrackContainer) ModifyContainerInformation() error {
|
||||
// Gets all the information of tracker containers
|
||||
err, t := ViewTrackedContainers()
|
||||
if err != nil {
|
||||
@@ -192,15 +192,15 @@ func (TC *TrackContainer)ModifyContainerInformation() error {
|
||||
}
|
||||
|
||||
// WriteContainers Write information back to the config file
|
||||
func (TC *TrackContainers)WriteContainers() error {
|
||||
func (TC *TrackContainers) WriteContainers() error {
|
||||
// Initialize config file
|
||||
config,err := config.ConfigInit()
|
||||
config, err := config.ConfigInit()
|
||||
// write modified information to the tracked json file
|
||||
data,err := json.MarshalIndent(TC, "", "\t")
|
||||
data, err := json.MarshalIndent(TC, "", "\t")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(config.TrackContainersPath,data,0777)
|
||||
err = ioutil.WriteFile(config.TrackContainersPath, data, 0777)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -209,12 +209,12 @@ func (TC *TrackContainers)WriteContainers() error {
|
||||
}
|
||||
|
||||
// CheckID Checks if the ID belongs to a group or a single container
|
||||
func CheckID(ID string) (string,error) {
|
||||
func CheckID(ID string) (string, error) {
|
||||
// For group checks if the 1st characters is "grp"
|
||||
if ID[0:3] == "grp" {
|
||||
return "group", nil
|
||||
} else {
|
||||
return "container", nil
|
||||
}
|
||||
return "",nil
|
||||
return "", nil
|
||||
}
|
||||
@@ -2,20 +2,20 @@ package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Tests a scenario where the container are getting tracked
|
||||
func TestAddTrackContainer(t *testing.T) {
|
||||
// Create docker container and get SSH port
|
||||
container1 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
// Testing the AddTrackContainer Function
|
||||
err = AddTrackContainer(container1,"0.0.0.0")
|
||||
err = AddTrackContainer(container1, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container1.ID)
|
||||
@@ -38,20 +38,20 @@ func TestAddTrackContainer(t *testing.T) {
|
||||
// NOTE: This test can also be considered as a whole flow on the process of
|
||||
// tracked containers
|
||||
func TestRemoveTrackedContainer(t *testing.T) {
|
||||
container1 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container1, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
container2 ,err := docker.BuildRunContainer(0,"false","")
|
||||
container2, err := docker.BuildRunContainer(0, "false", "")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
// Testing the AddTrackContainer Function and adding the first container created
|
||||
err = AddTrackContainer(container1,"0.0.0.0")
|
||||
err = AddTrackContainer(container1, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container1.ID)
|
||||
@@ -70,7 +70,7 @@ func TestRemoveTrackedContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
// Testing the AddTrackContainer Function and the adding the second container created
|
||||
err = AddTrackContainer(container2,"0.0.0.0")
|
||||
err = AddTrackContainer(container2, "0.0.0.0")
|
||||
if err != nil {
|
||||
// Killing docker container created
|
||||
err = docker.StopAndRemoveContainer(container2.ID)
|
||||
|
||||
@@ -3,8 +3,8 @@ package clientIPTable
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
|
||||
@@ -3,8 +3,8 @@ package client
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
@@ -2,13 +2,13 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/generate"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/plugin"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/generate"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/plugin"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package generate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/otiai10/copy"
|
||||
"go/ast"
|
||||
"go/token"
|
||||
|
||||
@@ -2,7 +2,7 @@ package generate
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestCreateFolder(t *testing.T) {
|
||||
// Testing if a new project is created successfully
|
||||
func TestGenerateNewProject(t *testing.T) {
|
||||
// Checking if a new project is created successfully
|
||||
err := GenerateNewProject("p2prctest","p2prctest")
|
||||
err := GenerateNewProject("p2prctest", "p2prctest")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
@@ -38,7 +38,7 @@ func TestChangingImportAST(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
// Create testcase scenario
|
||||
err = config.Copy(path + "testcaseAST.go", path + "/Test/testcaseAST.go")
|
||||
err = config.Copy(path+"testcaseAST.go", path+"/Test/testcaseAST.go")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
t.Error(err)
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module git.sr.ht/~akilan1999/p2p-rendering-computation
|
||||
module github.com/Akilan1999/p2p-rendering-computation
|
||||
|
||||
go 1.15
|
||||
|
||||
|
||||
4
main.go
4
main.go
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/cmd"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/cmd"
|
||||
"github.com/urfave/cli/v2"
|
||||
"log"
|
||||
"os"
|
||||
@@ -12,7 +12,7 @@ var VERSION = "1.5.0"
|
||||
var mode string
|
||||
|
||||
// Varaibles if mode is client
|
||||
var OS, Pull_location ,Run_script string
|
||||
var OS, Pull_location, Run_script string
|
||||
var List_servers, Ip_table bool
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package frp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/fatedier/frp/client"
|
||||
"github.com/fatedier/frp/pkg/config"
|
||||
"github.com/phayes/freeport"
|
||||
|
||||
@@ -3,7 +3,7 @@ package p2p
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
@@ -3,7 +3,7 @@ package p2p
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -29,7 +29,7 @@ func DownloadPlugin(pluginurl string) error {
|
||||
return err
|
||||
}
|
||||
// clones a repo and stores it at the plugin directory
|
||||
_, err = git.PlainClone(config.PluginPath + "/" + folder, false, &git.CloneOptions{
|
||||
_, err = git.PlainClone(config.PluginPath+"/"+folder, false, &git.CloneOptions{
|
||||
URL: pluginurl,
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
@@ -38,7 +38,6 @@ func DownloadPlugin(pluginurl string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/google/uuid"
|
||||
"gopkg.in/yaml.v2"
|
||||
"io/ioutil"
|
||||
|
||||
@@ -2,9 +2,9 @@ package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"net"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/client"
|
||||
@@ -65,7 +65,7 @@ var dockerRegistryUserID = ""
|
||||
|
||||
// BuildRunContainer Function is incharge to invoke building and running contianer and also allocating external
|
||||
// ports
|
||||
func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerVM,error) {
|
||||
func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerVM, error) {
|
||||
//Docker Struct Variable
|
||||
var RespDocker *DockerVM = new(DockerVM)
|
||||
|
||||
@@ -86,7 +86,7 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
// Get Path from config
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
RespDocker.ImagePath = config.DefaultDockerFile
|
||||
|
||||
@@ -95,7 +95,7 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
if ContainerName != "" && ContainerName != "docker-ubuntu-sshd" {
|
||||
Containers, err := ViewAllContainers()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, dockerContainer := range Containers.DockerContainer {
|
||||
@@ -121,7 +121,7 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
// Creates number of ports
|
||||
OpenPorts, err := freeport.GetFreePorts(count)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
// Allocate external ports to ports available in the ports.json file
|
||||
for i := range PortsInformation.PortSet {
|
||||
@@ -136,8 +136,8 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
var TempPort Port
|
||||
TempPort.PortName = "AutoGen Port"
|
||||
TempPort.Type = "tcp"
|
||||
TempPort.InternalPort = OpenPorts[portFileLength + i]
|
||||
TempPort.ExternalPort = OpenPorts[portFileLength + i]
|
||||
TempPort.InternalPort = OpenPorts[portFileLength+i]
|
||||
TempPort.ExternalPort = OpenPorts[portFileLength+i]
|
||||
TempPort.Description = "Auto generated TCP port"
|
||||
TempPort.IsUsed = false
|
||||
//Append temp port to port information
|
||||
@@ -149,29 +149,28 @@ func BuildRunContainer(NumPorts int, GPU string, ContainerName string) (*DockerV
|
||||
// Gets docker information from env variables
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Builds docker image
|
||||
err = RespDocker.imageBuild(cli)
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Runs docker contianer
|
||||
err = RespDocker.runContainer(cli)
|
||||
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
return RespDocker,nil
|
||||
return RespDocker, nil
|
||||
|
||||
}
|
||||
|
||||
//Builds docker image (TODO: relative path for Dockerfile deploy)
|
||||
func (d *DockerVM)imageBuild(dockerClient *client.Client) error {
|
||||
// Builds docker image (TODO: relative path for Dockerfile deploy)
|
||||
func (d *DockerVM) imageBuild(dockerClient *client.Client) error {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*2000)
|
||||
//defer cancel()
|
||||
|
||||
@@ -203,12 +202,11 @@ func (d *DockerVM)imageBuild(dockerClient *client.Client) error {
|
||||
// Starts container and assigns port numbers
|
||||
// Sample Docker run Command
|
||||
// docker run -d=true --name=Test123 --restart=always --gpus all
|
||||
//-p 3443:6901 -p 3453:22 -p 3434:3434 -p 3245:3245 -v=/opt/data:/data
|
||||
//p2p-ubuntu /start > /dev/null
|
||||
func (d *DockerVM)runContainer(dockerClient *client.Client) error{
|
||||
// -p 3443:6901 -p 3453:22 -p 3434:3434 -p 3245:3245 -v=/opt/data:/data
|
||||
// p2p-ubuntu /start > /dev/null
|
||||
func (d *DockerVM) runContainer(dockerClient *client.Client) error {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*2000)
|
||||
|
||||
|
||||
// The first mode runs using the Docker Api. As the API supports using
|
||||
// CPU and uses a shell script for GPU call because till this point of
|
||||
// implementation docker api does not support the flag "--gpu all"
|
||||
@@ -239,7 +237,7 @@ func (d *DockerVM)runContainer(dockerClient *client.Client) error{
|
||||
|
||||
for i := range d.Ports.PortSet {
|
||||
// Parameters "tcp or udp", external port
|
||||
Port, err := nat.NewPort(d.Ports.PortSet[i].Type,fmt.Sprint(d.Ports.PortSet[i].InternalPort))
|
||||
Port, err := nat.NewPort(d.Ports.PortSet[i].Type, fmt.Sprint(d.Ports.PortSet[i].InternalPort))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -286,11 +284,11 @@ func (d *DockerVM)runContainer(dockerClient *client.Client) error{
|
||||
d.ID = id
|
||||
|
||||
var cmd bytes.Buffer
|
||||
cmd.WriteString("docker run -d=true --name="+ id +" --restart=always --gpus all ")
|
||||
cmd.WriteString("docker run -d=true --name=" + id + " --restart=always --gpus all ")
|
||||
for i := range d.Ports.PortSet {
|
||||
cmd.WriteString("-p " + fmt.Sprint(d.Ports.PortSet[i].ExternalPort) + ":" + fmt.Sprint(d.Ports.PortSet[i].InternalPort) + " ")
|
||||
}
|
||||
cmd.WriteString("-v=/opt/data:/data "+ d.TagName +" /start > /dev/null")
|
||||
cmd.WriteString("-v=/opt/data:/data " + d.TagName + " /start > /dev/null")
|
||||
//"-v=/opt/data:/data p2p-ubuntu /start > /dev/null"
|
||||
cmdStr := cmd.String()
|
||||
_, err := exec.Command("/bin/sh", "-c", cmdStr).Output()
|
||||
@@ -330,11 +328,11 @@ func StopAndRemoveContainer(containername string) error {
|
||||
}
|
||||
|
||||
// ViewAllContainers returns all containers runnable and which can be built
|
||||
func ViewAllContainers() (*DockerContainers, error){
|
||||
func ViewAllContainers() (*DockerContainers, error) {
|
||||
// Traverse the deploy path as per given in the config file
|
||||
config, err := config.ConfigInit()
|
||||
if err != nil {
|
||||
return nil,err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
folders, err := ioutil.ReadDir(config.DockerContainers)
|
||||
@@ -366,7 +364,7 @@ func ViewAllContainers() (*DockerContainers, error){
|
||||
}
|
||||
}
|
||||
|
||||
return Containers,nil
|
||||
return Containers, nil
|
||||
}
|
||||
|
||||
func print(rd io.Reader) error {
|
||||
|
||||
@@ -2,7 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"net"
|
||||
"net/rpc"
|
||||
)
|
||||
@@ -18,8 +18,8 @@ type Docker struct {
|
||||
}
|
||||
|
||||
// Starts container using RPC calls
|
||||
func (l *Listener) StartContainer( reply *Docker) error {
|
||||
vm, err := docker.BuildRunContainer(3,"false","")
|
||||
func (l *Listener) StartContainer(reply *Docker) error {
|
||||
vm, err := docker.BuildRunContainer(3, "false", "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -28,8 +28,6 @@ func (l *Listener) StartContainer( reply *Docker) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
|
||||
func Rpc() {
|
||||
rpcServer, err := net.ResolveTCPAddr("tcp", "0.0.0.0:"+port)
|
||||
if err != nil {
|
||||
@@ -43,4 +41,3 @@ func Rpc() {
|
||||
rpc.Register(listener)
|
||||
rpc.Accept(inbound)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package server
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/config"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p/frp"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/client/clientIPTable"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/config"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/p2p/frp"
|
||||
"github.com/Akilan1999/p2p-rendering-computation/server/docker"
|
||||
"github.com/gin-gonic/gin"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
Reference in New Issue
Block a user