Added create docker image route and intergrated with the client

This commit is contained in:
2021-04-02 02:33:16 +04:00
parent a7dc4cbce4
commit 53ba23ebf9
11 changed files with 172 additions and 55 deletions

View File

@@ -1,19 +1,35 @@
package cmd
import (
"fmt"
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
"git.sr.ht/~akilan1999/p2p-rendering-computation/p2p"
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
"github.com/urfave/cli/v2"
)
var CliAction = func(ctx *cli.Context) error {
if Mode == "server" {
// TODO: with RPC calls
server.Server()
//server.Rpc()
}
//Listing servers avaliable
if List_servers {
p2p.PrintIpTable()
}
//Call function to create Docker container
if IpAddress != "" {
imageRes, err := client.StartContainer(IpAddress)
if err != nil {
fmt.Print(err)
}
client.PrintStartContainer(imageRes)
}
return nil
}

View File

@@ -5,13 +5,13 @@ import (
)
var Mode,IpAddress string
var List_servers, Ip_table bool
var List_servers, Ip_table, Abspath bool
var AppConfigFlags = []cli.Flag{
// Deprecated to be implemented using GRPC
&cli.StringFlag{
Name: "Mode",
Value: "server",
Value: "client",
Usage: "Specifies mode of running",
EnvVars: []string{"P2P_MODE"},
Destination: &Mode,
@@ -28,4 +28,10 @@ var AppConfigFlags = []cli.Flag{
EnvVars: []string{"CREATE_VM"},
Destination: &IpAddress,
},
&cli.BoolFlag{
Name: "FilePath",
Usage: "Testing for absolute path",
EnvVars: []string{"CREATE_VM"},
Destination: &Abspath,
},
}