Merge pull request #10 from Akilan1999/error-speed-test-not-pingable

Fixing issues for deleting elements from IP tables
This commit is contained in:
Akilan Selvacoumar
2021-05-24 21:39:32 +04:00
committed by GitHub
13 changed files with 47 additions and 87 deletions

2
.gitignore vendored
View File

@@ -1,7 +1,9 @@
.idea
vendor/
bin/
p2p-rendering/
main
server/docker/__pycache__
p2p-rendering-computation
p2prc
config.json

8
.idea/.gitignore generated vendored
View File

@@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/

8
.idea/modules.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/p2p-redering-computation.iml" filepath="$PROJECT_DIR$/.idea/p2p-redering-computation.iml" />
</modules>
</component>
</project>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python facet">
<configuration sdkName="Python 3.8 (p2p-redering-computation)" />
</facet>
</component>
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 3.8 (p2p-redering-computation) interpreter library" level="application" />
</component>
</module>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated
View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@@ -13,6 +13,7 @@ in the developer community. In the server module we use the Docker Go API to cre
interact with the containers.
[Instructions to install docker](https://docs.docker.com/get-docker/)
[Instructions to install docker GPU](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker)
````
Do ensure that the docker command does not need sudo to run
@@ -27,7 +28,7 @@ make install
### Test if binary works
```
./p2p-rendering-computation --help
p2prc --help
```
#### Output:
```
@@ -60,10 +61,6 @@ GLOBAL OPTIONS:
```
### Add command to .bashrc or .zshrc
```
export PATH=~/<Project Path>/p2p-redering-computation:${PATH}
```
#### Note: The steps on how to use the commands will be added later.

View File

@@ -1,11 +1,16 @@
SHELL := /bin/bash
install:
go build .
./p2p-rendering-computation --SetDefaultConfig
go build -o p2prc
echo '# Paths for p2p rendering and computation' >> ~/.bashrc
echo 'export P2PRC=${PWD}' >> ~/.bashrc
echo 'export ${PWD}:$${PATH}' >> ~/.bashrc
source ~/.bashrc
./p2prc --SetDefaultConfig
build:
go build .
go build -o p2prc
config:
./p2p-rendering-computation --SetDefaultConfig

View File

@@ -12,7 +12,7 @@ var (
"DockerFile": "/home/akilan/Documents/p2prendering/p2p-redering-computation/server/docker/containers/docker-ubuntu-sshd/",
"SpeedTestFile":"/etc/p2p-rendering/50.bin",
}
configName = "config.json"
configName = "config"
configType = "json"
configFile = "config.json"
configPaths []string
@@ -37,11 +37,8 @@ func fileExists(name string) bool {
// SetDefaults This function to be called only during a
// make install
func SetDefaults() error {
//Getting Current Directory
curDir, err := os.Getwd()
if err != nil {
return err
}
//Getting Current Directory from environment variable
curDir := os.Getenv("P2PRC")
//Setting current directory to default path
defaultPath = curDir + "/"
@@ -62,7 +59,7 @@ func SetDefaults() error {
}
//Calling configuration file
_, err = ConfigInit()
_, err := ConfigInit()
if err != nil {
return err
}
@@ -70,23 +67,32 @@ func SetDefaults() error {
}
func ConfigInit()(*Config,error) {
//Sets default configuration to viper
for k,v := range defaults {
viper.SetDefault(k,v)
}
viper.SetConfigName(configName)
viper.SetConfigFile(configFile)
viper.SetConfigType(configType)
curDir := os.Getenv("P2PRC")
//Setting current directory to default path
defaultPath = curDir + "/"
//Paths to search for config file
configPaths = append(configPaths, defaultPath)
//Add all possible configurations paths
for _,v := range configPaths {
viper.AddConfigPath(v)
}
//Read config file
if err := viper.ReadInConfig(); err != nil {
// If the error thrown is config file not found
if err = viper.WriteConfig(); err != nil {
return nil,err
}
//Sets default configuration to viper
for k,v := range defaults {
viper.SetDefault(k,v)
}
viper.SetConfigName(configName)
viper.SetConfigFile(configFile)
viper.SetConfigType(configType)
if err = viper.WriteConfig(); err != nil {
return nil,err
}
}
// Adds configuration to the struct

1
go.mod
View File

@@ -29,6 +29,7 @@ require (
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
golang.org/x/tools v0.0.0-20210106214847-113979e3529a
google.golang.org/grpc v1.35.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/v3 v3.0.3 // indirect

1
go.sum
View File

@@ -820,6 +820,7 @@ golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapK
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@@ -1,16 +1,3 @@
{
"ip_address": [
{
"ipv4": "147.75.100.225",
"latency": 1582411,
"download": 279180.07603469375,
"upload": 855366.1394760027
},
{
"ipv4": "86.99.70.106",
"latency": 134446840,
"download": 1582.176490711659,
"upload": 597823.3252726822
}
]
"ip_address": null
}

View File

@@ -8,9 +8,9 @@ func (ip *IpAddresses)SpeedTest() error{
for i, value := range ip.IpAddress {
var err error
if len(ip.IpAddress) == 1 {
i = 0
}
//if len(ip.IpAddress) == 1 {
// i = 0
//}
// Ping Test
err = value.PingTest()
@@ -40,6 +40,12 @@ func (ip *IpAddresses)SpeedTest() error{
}
// Remove element from struct
for _, index := range RemoveIndex {
// If there is only 1 element and that has to be
// removed
if len(ip.IpAddress) == 1 {
ip.IpAddress = nil
break
}
ip.IpAddress = append(ip.IpAddress[:index], ip.IpAddress[index+1:]...)
}