added cli command add server
This commit is contained in:
@@ -26,10 +26,32 @@ var CliAction = func(ctx *cli.Context) error {
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
// Displays the IP table
|
||||
if ServerList {
|
||||
p2p.PrintIpTable()
|
||||
}
|
||||
|
||||
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
|
||||
IpAddr.Ipv4 = AddServer
|
||||
|
||||
// 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()
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Function called to stop and remove server from Docker
|
||||
if RemoveVM != "" && ID != "" {
|
||||
err := client.RemoveContianer(RemoveVM,ID)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
// Variables declared for CLI
|
||||
var (
|
||||
AddServer string
|
||||
CreateVM string
|
||||
Ports string
|
||||
Mode string
|
||||
@@ -39,6 +40,12 @@ var AppConfigFlags = []cli.Flag{
|
||||
EnvVars: []string{"LIST_SERVERS"},
|
||||
Destination: &ServerList,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "AddServer",
|
||||
Usage: "Adds server IP address to iptables",
|
||||
EnvVars: []string{"ADD_SERVER"},
|
||||
Destination: &AddServer,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "CreateVM",
|
||||
Usage: "Creates Docker container on the selected server",
|
||||
|
||||
Reference in New Issue
Block a user