added auto reverse proxy detection and applicable for docker container
This commit is contained in:
520
cmd/action.go
520
cmd/action.go
@@ -1,294 +1,304 @@
|
||||
package cmd
|
||||
|
||||
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/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/urfave/cli/v2"
|
||||
"fmt"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/client"
|
||||
"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/p2p/frp"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/plugin"
|
||||
"git.sr.ht/~akilan1999/p2p-rendering-computation/server"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
var CliAction = func(ctx *cli.Context) error {
|
||||
if Server {
|
||||
// TODO: with RPC calls
|
||||
server.Server()
|
||||
//server.Rpc()
|
||||
}
|
||||
if Server {
|
||||
err := server.Server()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
//server.Rpc()
|
||||
}
|
||||
|
||||
//Listing servers and also updates IP tables (Default 3 hops)
|
||||
if UpdateServerList {
|
||||
err := client.UpdateIpTableListClient()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
// Reads from ip table and passes it
|
||||
// on to struct print function
|
||||
//Servers, err := p2p.ReadIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//client.PrettyPrint(Servers)
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
//Listing servers and also updates IP tables (Default 3 hops)
|
||||
if UpdateServerList {
|
||||
err := client.UpdateIpTableListClient()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
// Reads from ip table and passes it
|
||||
// on to struct print function
|
||||
//Servers, err := p2p.ReadIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
//client.PrettyPrint(Servers)
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
// Displays the IP table
|
||||
if ServerList {
|
||||
// Reads from ip table and passes it
|
||||
// on to struct print function
|
||||
//Servers, err := p2p.ReadIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
// Displays the IP table
|
||||
if ServerList {
|
||||
// Reads from ip table and passes it
|
||||
// on to struct print function
|
||||
//Servers, err := p2p.ReadIpTable()
|
||||
//if err != nil {
|
||||
// return err
|
||||
//}
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
// Add provided IP to the IP table
|
||||
if AddServer != "" {
|
||||
res, err := p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
// Add provided IP to the IP table
|
||||
if AddServer != "" {
|
||||
res, err := p2p.ReadIpTable()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
//Create variable of type IpAddress and set IP address
|
||||
// to it
|
||||
var IpAddr p2p.IpAddress
|
||||
//Create variable of type IpAddress and set IP address
|
||||
// to it
|
||||
var IpAddr p2p.IpAddress
|
||||
|
||||
//Checking if the address is a ipv4
|
||||
// or ipv6 address
|
||||
ip4Orip6 := p2p.Ip4or6(AddServer)
|
||||
if ip4Orip6 == "version 6" {
|
||||
IpAddr.Ipv6 = AddServer
|
||||
} else {
|
||||
IpAddr.Ipv4 = AddServer
|
||||
}
|
||||
//Checking if the address is a ipv4
|
||||
// or ipv6 address
|
||||
ip4Orip6 := p2p.Ip4or6(AddServer)
|
||||
if ip4Orip6 == "version 6" {
|
||||
IpAddr.Ipv6 = AddServer
|
||||
} else {
|
||||
IpAddr.Ipv4 = AddServer
|
||||
}
|
||||
|
||||
// If a server port is provided then set it
|
||||
if Ports != "" {
|
||||
IpAddr.ServerPort = Ports
|
||||
} else {
|
||||
IpAddr.ServerPort = "8088"
|
||||
}
|
||||
// Append IP address to variable result which
|
||||
// is a list
|
||||
res.IpAddress = append(res.IpAddress, IpAddr)
|
||||
// Adds the new server IP to the iptable
|
||||
res.WriteIpTable()
|
||||
// If a server port is provided then set it
|
||||
if Ports != "" {
|
||||
IpAddr.ServerPort = Ports
|
||||
} else {
|
||||
IpAddr.ServerPort = "8088"
|
||||
}
|
||||
// Append IP address to variable result which
|
||||
// is a list
|
||||
res.IpAddress = append(res.IpAddress, IpAddr)
|
||||
// Adds the new server IP to the iptable
|
||||
res.WriteIpTable()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// Displays all images available on the server side
|
||||
if ViewImages != "" {
|
||||
imageRes, err := client.ViewContainers(ViewImages)
|
||||
|
||||
// Displays all images available on the server side
|
||||
if ViewImages != "" {
|
||||
imageRes, err := client.ViewContainers(ViewImages)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
}
|
||||
// Function called to stop and remove server from Docker
|
||||
if RemoveVM != "" && ID != "" {
|
||||
err := client.RemoveContianer(RemoveVM, ID)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Function called to stop and remove server from Docker
|
||||
if RemoveVM != "" && ID != "" {
|
||||
err := client.RemoveContianer(RemoveVM,ID)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
//Call function to create Docker container
|
||||
if CreateVM != "" {
|
||||
|
||||
//Call function to create Docker container
|
||||
if CreateVM != "" {
|
||||
var PortsInt int
|
||||
|
||||
var PortsInt int
|
||||
if Ports != "" {
|
||||
// Convert Get Request value to int
|
||||
fmt.Sscanf(Ports, "%d", &PortsInt)
|
||||
}
|
||||
|
||||
if Ports != "" {
|
||||
// Convert Get Request value to int
|
||||
fmt.Sscanf(Ports, "%d", &PortsInt)
|
||||
}
|
||||
// Calls function to do Api call to start the container on the server side
|
||||
imageRes, err := client.StartContainer(CreateVM, PortsInt, GPU, ContainerName)
|
||||
|
||||
// Calls function to do Api call to start the container on the server side
|
||||
imageRes, err := client.StartContainer(CreateVM,PortsInt,GPU,ContainerName)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(imageRes)
|
||||
}
|
||||
//Call if specs flag is called
|
||||
if Specs != "" {
|
||||
specs, err := client.GetSpecs(Specs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//Call if specs flag is called
|
||||
if Specs != "" {
|
||||
specs, err := client.GetSpecs(Specs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Pretty print
|
||||
client.PrettyPrint(specs)
|
||||
}
|
||||
|
||||
// Pretty print
|
||||
client.PrettyPrint(specs)
|
||||
}
|
||||
//Sets default paths to the config file
|
||||
if SetDefaultConfig {
|
||||
err := config.SetDefaults()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
//Sets default paths to the config file
|
||||
if SetDefaultConfig {
|
||||
err := config.SetDefaults()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
//If the network interface flag is called
|
||||
// Then all the network interfaces are displayed
|
||||
if NetworkInterface {
|
||||
err := p2p.ViewNetworkInterface()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
|
||||
//If the network interface flag is called
|
||||
// Then all the network interfaces are displayed
|
||||
if NetworkInterface {
|
||||
err := p2p.ViewNetworkInterface()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
}
|
||||
// If the view plugin flag is called then display all
|
||||
// plugins available
|
||||
if ViewPlugin {
|
||||
plugins, err := plugin.DetectPlugins()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(plugins)
|
||||
}
|
||||
|
||||
// If the view plugin flag is called then display all
|
||||
// plugins available
|
||||
if ViewPlugin {
|
||||
plugins ,err := plugin.DetectPlugins()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(plugins)
|
||||
}
|
||||
// If the flag Tracked Container is called or the flag
|
||||
// --tc
|
||||
if TrackedContainers {
|
||||
err, trackedContainers := client.ViewTrackedContainers()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(trackedContainers)
|
||||
}
|
||||
|
||||
// If the flag Tracked Container is called or the flag
|
||||
// --tc
|
||||
if TrackedContainers {
|
||||
err, trackedContainers := client.ViewTrackedContainers()
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
}
|
||||
client.PrettyPrint(trackedContainers)
|
||||
}
|
||||
//Executing plugin when the plugin flag is called
|
||||
// --plugin
|
||||
if ExecutePlugin != "" {
|
||||
// To execute plugin requires the container ID or group ID provided when being executed
|
||||
if ID != "" {
|
||||
err := plugin.CheckRunPlugin(ExecutePlugin, ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("provide container ID")
|
||||
}
|
||||
|
||||
//Executing plugin when the plugin flag is called
|
||||
// --plugin
|
||||
if ExecutePlugin != "" {
|
||||
// To execute plugin requires the container ID or group ID provided when being executed
|
||||
if ID != "" {
|
||||
err := plugin.CheckRunPlugin(ExecutePlugin, ID)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
} else {
|
||||
fmt.Println("provide container ID")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// Executing function to create new group
|
||||
// Creates new group and outputs JSON file
|
||||
if CreateGroup {
|
||||
group, err := client.CreateGroup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
|
||||
// Executing function to create new group
|
||||
// Creates new group and outputs JSON file
|
||||
if CreateGroup {
|
||||
group, err := client.CreateGroup()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
// Actions to be performed when the
|
||||
// group flag is called
|
||||
// --group <Group ID>
|
||||
if Group != "" {
|
||||
// Remove container from group based on group ID provided
|
||||
// --rmcgroup --id <contianer id>
|
||||
if RemoveContainerGroup && ID != "" {
|
||||
group, err := client.RemoveContainerGroup(ID, Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
} else if ID != "" { // Add container to group based on group ID provided
|
||||
// --id <Container ID>
|
||||
group, err := client.AddContainerToGroup(ID, Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
} else { // View all information about current group
|
||||
group, err := client.GetGroup(Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actions to be performed when the
|
||||
// group flag is called
|
||||
// --group <Group ID>
|
||||
if Group != "" {
|
||||
// Remove container from group based on group ID provided
|
||||
// --rmcgroup --id <contianer id>
|
||||
if RemoveContainerGroup && ID != "" {
|
||||
group, err := client.RemoveContainerGroup(ID, Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
} else if ID != "" { // Add container to group based on group ID provided
|
||||
// --id <Container ID>
|
||||
group, err := client.AddContainerToGroup(ID,Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
} else { // View all information about current group
|
||||
group, err := client.GetGroup(Group)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(group)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Execute function to remove entire group
|
||||
// when remove group flag is called
|
||||
// --rmgroup
|
||||
if RemoveGroup != "" {
|
||||
err := client.RemoveGroup(RemoveGroup)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Group Removed")
|
||||
}
|
||||
}
|
||||
|
||||
// Execute function to remove entire group
|
||||
// when remove group flag is called
|
||||
// --rmgroup
|
||||
if RemoveGroup != "" {
|
||||
err := client.RemoveGroup(RemoveGroup)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Group Removed")
|
||||
}
|
||||
}
|
||||
// Execute Function to view all groups
|
||||
if Groups {
|
||||
groups, err := client.ReadGroup()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(groups)
|
||||
}
|
||||
}
|
||||
|
||||
// Execute Function to view all groups
|
||||
if Groups {
|
||||
groups, err := client.ReadGroup()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
client.PrettyPrint(groups)
|
||||
}
|
||||
}
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
// when flag --gen is called an extension
|
||||
// of the project is created to repurpose
|
||||
// the project for custom purpose
|
||||
if Generate != "" {
|
||||
var err error
|
||||
// If the module name is provided
|
||||
if Modulename != "" {
|
||||
err = generate.GenerateNewProject(Generate,Modulename)
|
||||
} else {
|
||||
err = generate.GenerateNewProject(Generate,Generate)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Created new folder: " + Generate)
|
||||
fmt.Println("1. Enter inside " + Generate + " directory")
|
||||
fmt.Println("2. git remote add " + Generate + " <PATH to the github repo>")
|
||||
fmt.Println("3. git push " + Generate + " <PATH to the github repo>")
|
||||
fmt.Println("4. go mod tidy")
|
||||
fmt.Println("5. sh install.sh " + Generate)
|
||||
fmt.Println("6. ./" + Generate + " -h (This is to test if the binary is working)")
|
||||
}
|
||||
}
|
||||
//--------------------------------
|
||||
// Starts server as a reverse proxy so that
|
||||
// nodes can connect to each other behind NAT
|
||||
if FRPProxy {
|
||||
err := frp.StartFRPProxyFromConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
if PullPlugin != "" {
|
||||
err := plugin.DownloadPlugin(PullPlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
}
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
// when flag --gen is called an extension
|
||||
// of the project is created to repurpose
|
||||
// the project for custom purpose
|
||||
if Generate != "" {
|
||||
var err error
|
||||
// If the module name is provided
|
||||
if Modulename != "" {
|
||||
err = generate.GenerateNewProject(Generate, Modulename)
|
||||
} else {
|
||||
err = generate.GenerateNewProject(Generate, Generate)
|
||||
}
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Created new folder: " + Generate)
|
||||
fmt.Println("1. Enter inside " + Generate + " directory")
|
||||
fmt.Println("2. git remote add " + Generate + " <PATH to the github repo>")
|
||||
fmt.Println("3. git push " + Generate + " <PATH to the github repo>")
|
||||
fmt.Println("4. go mod tidy")
|
||||
fmt.Println("5. sh install.sh " + Generate)
|
||||
fmt.Println("6. ./" + Generate + " -h (This is to test if the binary is working)")
|
||||
}
|
||||
}
|
||||
//--------------------------------
|
||||
|
||||
if RemovePlugin != "" {
|
||||
err := plugin.DeletePlugin(RemovePlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
}
|
||||
if PullPlugin != "" {
|
||||
err := plugin.DownloadPlugin(PullPlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
}
|
||||
|
||||
if RemovePlugin != "" {
|
||||
err := plugin.DeletePlugin(RemovePlugin)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nil
|
||||
return nil
|
||||
}
|
||||
|
||||
444
cmd/flags.go
444
cmd/flags.go
@@ -1,228 +1,236 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Variables declared for CLI
|
||||
var (
|
||||
AddServer string
|
||||
ViewImages string
|
||||
CreateVM string
|
||||
ContainerName string
|
||||
Ports string
|
||||
Server bool
|
||||
RemoveVM string
|
||||
ID string
|
||||
Specs string
|
||||
GPU bool
|
||||
UpdateServerList bool
|
||||
ServerList bool
|
||||
SetDefaultConfig bool
|
||||
NetworkInterface bool
|
||||
ViewPlugin bool
|
||||
TrackedContainers bool
|
||||
ExecutePlugin string
|
||||
CreateGroup bool
|
||||
Group string
|
||||
Groups bool
|
||||
RemoveContainerGroup bool
|
||||
RemoveGroup string
|
||||
// Generate only allowed in dev release
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
Generate string
|
||||
Modulename string
|
||||
//--------------------------------
|
||||
PullPlugin string
|
||||
RemovePlugin string
|
||||
AddServer string
|
||||
ViewImages string
|
||||
CreateVM string
|
||||
ContainerName string
|
||||
Ports string
|
||||
Server bool
|
||||
RemoveVM string
|
||||
ID string
|
||||
Specs string
|
||||
GPU bool
|
||||
UpdateServerList bool
|
||||
ServerList bool
|
||||
SetDefaultConfig bool
|
||||
NetworkInterface bool
|
||||
ViewPlugin bool
|
||||
TrackedContainers bool
|
||||
ExecutePlugin string
|
||||
CreateGroup bool
|
||||
Group string
|
||||
Groups bool
|
||||
RemoveContainerGroup bool
|
||||
RemoveGroup string
|
||||
FRPProxy bool
|
||||
// Generate only allowed in dev release
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
Generate string
|
||||
Modulename string
|
||||
//--------------------------------
|
||||
PullPlugin string
|
||||
RemovePlugin string
|
||||
)
|
||||
|
||||
var AppConfigFlags = []cli.Flag{
|
||||
// Deprecated to be implemented using GRPC
|
||||
&cli.BoolFlag{
|
||||
Name: "Server",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "Starts server",
|
||||
EnvVars: []string{"SERVER"},
|
||||
Destination: &Server,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "UpdateServerList",
|
||||
Aliases: []string{"us"},
|
||||
Usage: "Update List of Server available based on servers iptables",
|
||||
EnvVars: []string{"UPDATE_SERVER_LIST"},
|
||||
Destination: &UpdateServerList,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ListServers",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List servers which can render tasks",
|
||||
EnvVars: []string{"LIST_SERVERS"},
|
||||
Destination: &ServerList,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "AddServer",
|
||||
Aliases: []string{"as"},
|
||||
Usage: "Adds server IP address to iptables",
|
||||
EnvVars: []string{"ADD_SERVER"},
|
||||
Destination: &AddServer,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ViewImages",
|
||||
Aliases: []string{"vi"},
|
||||
Usage: "View images available on the server IP address",
|
||||
EnvVars: []string{"VIEW_IMAGES"},
|
||||
Destination: &ViewImages,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "CreateVM",
|
||||
Aliases: []string{"touch"},
|
||||
Usage: "Creates Docker container on the selected server",
|
||||
EnvVars: []string{"CREATE_VM"},
|
||||
Destination: &CreateVM,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ContainerName",
|
||||
Aliases: []string{"cn"},
|
||||
Usage: "Specifying the container run on the server side",
|
||||
EnvVars: []string{"CONTAINER_NAME"},
|
||||
Destination: &ContainerName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemoveVM",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Stop and Remove Docker container",
|
||||
EnvVars: []string{"REMOVE_VM"},
|
||||
Destination: &RemoveVM,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ID",
|
||||
Aliases: []string{"id"},
|
||||
Usage: "Docker Container ID",
|
||||
EnvVars: []string{"ID"},
|
||||
Destination: &ID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Ports",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "Number of ports to open for the Docker Container",
|
||||
EnvVars: []string{"NUM_PORTS"},
|
||||
Destination: &Ports,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "GPU",
|
||||
Aliases: []string{"gpu"},
|
||||
Usage: "Create Docker Containers to access GPU",
|
||||
EnvVars: []string{"USE_GPU"},
|
||||
Destination: &GPU,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Specification",
|
||||
Aliases: []string{"specs"},
|
||||
Usage: "Specs of the server node",
|
||||
EnvVars: []string{"SPECS"},
|
||||
Destination: &Specs,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "SetDefaultConfig",
|
||||
Aliases: []string{"dc"},
|
||||
Usage: "Sets a default configuration file",
|
||||
EnvVars: []string{"SET_DEFAULT_CONFIG"},
|
||||
Destination: &SetDefaultConfig,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "NetworkInterfaces",
|
||||
Aliases: []string{"ni"},
|
||||
Usage: "Shows the network interface in your computer",
|
||||
EnvVars: []string{"NETWORK_INTERFACE"},
|
||||
Destination: &NetworkInterface,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ViewPlugins",
|
||||
Aliases: []string{"vp"},
|
||||
Usage: "Shows plugins available to be executed",
|
||||
EnvVars: []string{"VIEW_PLUGIN"},
|
||||
Destination: &ViewPlugin,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "TrackedContainers",
|
||||
Aliases: []string{"tc"},
|
||||
Usage: "View containers which have " +
|
||||
"been created from the client side ",
|
||||
EnvVars: []string{"TRACKED_CONTAINERS"},
|
||||
Destination: &TrackedContainers,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ExecutePlugin",
|
||||
Aliases: []string{"plugin"},
|
||||
Usage: "Plugin which needs to be executed",
|
||||
EnvVars: []string{"EXECUTE_PLUGIN"},
|
||||
Destination: &ExecutePlugin,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "CreateGroup",
|
||||
Aliases: []string{"cgroup"},
|
||||
Usage: "Creates a new group",
|
||||
EnvVars: []string{"CREATE_GROUP"},
|
||||
Destination: &CreateGroup,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Group",
|
||||
Aliases: []string{"group"},
|
||||
Usage: "group flag with argument group ID",
|
||||
EnvVars: []string{"GROUP"},
|
||||
Destination: &Group,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "Groups",
|
||||
Aliases: []string{"groups"},
|
||||
Usage: "View all groups",
|
||||
EnvVars: []string{"GROUPS"},
|
||||
Destination: &Groups,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "RemoveContainerGroup",
|
||||
Aliases: []string{"rmcgroup"},
|
||||
Usage: "Remove specific container in the group",
|
||||
EnvVars: []string{"REMOVE_CONTAINER_GROUP"},
|
||||
Destination: &RemoveContainerGroup,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemoveGroup",
|
||||
Aliases: []string{"rmgroup"},
|
||||
Usage: "Removes the entire group",
|
||||
EnvVars: []string{"REMOVE_GROUP"},
|
||||
Destination: &RemoveGroup,
|
||||
},
|
||||
// Generate only allowed in dev release
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
&cli.StringFlag{
|
||||
Name: "Generate",
|
||||
Aliases: []string{"gen"},
|
||||
Usage: "Generates a new copy of P2PRC which can be modified based on your needs",
|
||||
EnvVars: []string{"GENERATE"},
|
||||
Destination: &Generate,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ModuleName",
|
||||
Aliases: []string{"mod"},
|
||||
Usage: "New go project module name",
|
||||
EnvVars: []string{"MODULENAME"},
|
||||
Destination: &Modulename,
|
||||
},
|
||||
//--------------------------------
|
||||
&cli.StringFlag{
|
||||
Name: "PullPlugin",
|
||||
Aliases: []string{"pp"},
|
||||
Usage: "Pulls plugin from git repos",
|
||||
EnvVars: []string{"PULLPLUGIN"},
|
||||
Destination: &PullPlugin,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemovePlugin",
|
||||
Aliases: []string{"rp"},
|
||||
Usage: "Removes plugin",
|
||||
EnvVars: []string{"REMOVEPLUGIN"},
|
||||
Destination: &RemovePlugin,
|
||||
},
|
||||
}
|
||||
// Deprecated to be implemented using GRPC
|
||||
&cli.BoolFlag{
|
||||
Name: "Server",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "Starts server",
|
||||
EnvVars: []string{"SERVER"},
|
||||
Destination: &Server,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "UpdateServerList",
|
||||
Aliases: []string{"us"},
|
||||
Usage: "Update List of Server available based on servers iptables",
|
||||
EnvVars: []string{"UPDATE_SERVER_LIST"},
|
||||
Destination: &UpdateServerList,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ListServers",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "List servers which can render tasks",
|
||||
EnvVars: []string{"LIST_SERVERS"},
|
||||
Destination: &ServerList,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "AddServer",
|
||||
Aliases: []string{"as"},
|
||||
Usage: "Adds server IP address to iptables",
|
||||
EnvVars: []string{"ADD_SERVER"},
|
||||
Destination: &AddServer,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ViewImages",
|
||||
Aliases: []string{"vi"},
|
||||
Usage: "View images available on the server IP address",
|
||||
EnvVars: []string{"VIEW_IMAGES"},
|
||||
Destination: &ViewImages,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "CreateVM",
|
||||
Aliases: []string{"touch"},
|
||||
Usage: "Creates Docker container on the selected server",
|
||||
EnvVars: []string{"CREATE_VM"},
|
||||
Destination: &CreateVM,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ContainerName",
|
||||
Aliases: []string{"cn"},
|
||||
Usage: "Specifying the container run on the server side",
|
||||
EnvVars: []string{"CONTAINER_NAME"},
|
||||
Destination: &ContainerName,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemoveVM",
|
||||
Aliases: []string{"rm"},
|
||||
Usage: "Stop and Remove Docker container",
|
||||
EnvVars: []string{"REMOVE_VM"},
|
||||
Destination: &RemoveVM,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ID",
|
||||
Aliases: []string{"id"},
|
||||
Usage: "Docker Container ID",
|
||||
EnvVars: []string{"ID"},
|
||||
Destination: &ID,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Ports",
|
||||
Aliases: []string{"p"},
|
||||
Usage: "Number of ports to open for the Docker Container",
|
||||
EnvVars: []string{"NUM_PORTS"},
|
||||
Destination: &Ports,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "GPU",
|
||||
Aliases: []string{"gpu"},
|
||||
Usage: "Create Docker Containers to access GPU",
|
||||
EnvVars: []string{"USE_GPU"},
|
||||
Destination: &GPU,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Specification",
|
||||
Aliases: []string{"specs"},
|
||||
Usage: "Specs of the server node",
|
||||
EnvVars: []string{"SPECS"},
|
||||
Destination: &Specs,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "SetDefaultConfig",
|
||||
Aliases: []string{"dc"},
|
||||
Usage: "Sets a default configuration file",
|
||||
EnvVars: []string{"SET_DEFAULT_CONFIG"},
|
||||
Destination: &SetDefaultConfig,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "NetworkInterfaces",
|
||||
Aliases: []string{"ni"},
|
||||
Usage: "Shows the network interface in your computer",
|
||||
EnvVars: []string{"NETWORK_INTERFACE"},
|
||||
Destination: &NetworkInterface,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ViewPlugins",
|
||||
Aliases: []string{"vp"},
|
||||
Usage: "Shows plugins available to be executed",
|
||||
EnvVars: []string{"VIEW_PLUGIN"},
|
||||
Destination: &ViewPlugin,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "TrackedContainers",
|
||||
Aliases: []string{"tc"},
|
||||
Usage: "View containers which have " +
|
||||
"been created from the client side ",
|
||||
EnvVars: []string{"TRACKED_CONTAINERS"},
|
||||
Destination: &TrackedContainers,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ExecutePlugin",
|
||||
Aliases: []string{"plugin"},
|
||||
Usage: "Plugin which needs to be executed",
|
||||
EnvVars: []string{"EXECUTE_PLUGIN"},
|
||||
Destination: &ExecutePlugin,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "CreateGroup",
|
||||
Aliases: []string{"cgroup"},
|
||||
Usage: "Creates a new group",
|
||||
EnvVars: []string{"CREATE_GROUP"},
|
||||
Destination: &CreateGroup,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "Group",
|
||||
Aliases: []string{"group"},
|
||||
Usage: "group flag with argument group ID",
|
||||
EnvVars: []string{"GROUP"},
|
||||
Destination: &Group,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "Groups",
|
||||
Aliases: []string{"groups"},
|
||||
Usage: "View all groups",
|
||||
EnvVars: []string{"GROUPS"},
|
||||
Destination: &Groups,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "RemoveContainerGroup",
|
||||
Aliases: []string{"rmcgroup"},
|
||||
Usage: "Remove specific container in the group",
|
||||
EnvVars: []string{"REMOVE_CONTAINER_GROUP"},
|
||||
Destination: &RemoveContainerGroup,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemoveGroup",
|
||||
Aliases: []string{"rmgroup"},
|
||||
Usage: "Removes the entire group",
|
||||
EnvVars: []string{"REMOVE_GROUP"},
|
||||
Destination: &RemoveGroup,
|
||||
},
|
||||
// Generate only allowed in dev release
|
||||
// -- REMOVE ON REGULAR RELEASE --
|
||||
&cli.StringFlag{
|
||||
Name: "Generate",
|
||||
Aliases: []string{"gen"},
|
||||
Usage: "Generates a new copy of P2PRC which can be modified based on your needs",
|
||||
EnvVars: []string{"GENERATE"},
|
||||
Destination: &Generate,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ModuleName",
|
||||
Aliases: []string{"mod"},
|
||||
Usage: "New go project module name",
|
||||
EnvVars: []string{"MODULENAME"},
|
||||
Destination: &Modulename,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "FRPServerProxy",
|
||||
Aliases: []string{"proxy"},
|
||||
Usage: "Starts proxy for server",
|
||||
EnvVars: []string{"FRPSERVERPROXY"},
|
||||
Destination: &FRPProxy,
|
||||
},
|
||||
//--------------------------------
|
||||
&cli.StringFlag{
|
||||
Name: "PullPlugin",
|
||||
Aliases: []string{"pp"},
|
||||
Usage: "Pulls plugin from git repos",
|
||||
EnvVars: []string{"PULLPLUGIN"},
|
||||
Destination: &PullPlugin,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "RemovePlugin",
|
||||
Aliases: []string{"rp"},
|
||||
Usage: "Removes plugin",
|
||||
EnvVars: []string{"REMOVEPLUGIN"},
|
||||
Destination: &RemovePlugin,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user