Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #337 from markdryan/master
Browse files Browse the repository at this point in the history
ciao-launcher: Update the -network parameter
  • Loading branch information
Samuel Ortiz authored Jul 4, 2016
2 parents e4e08f6 + dc26b3d commit b68ed47
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 50 deletions.
8 changes: 4 additions & 4 deletions ciao-launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Currently, this is the only data source supported by launcher.

ciao-launcher can be launched from the command line as follows
```
sudo ciao-launcher -network [cn|nn|none]
sudo ciao-launcher
```

Currently, launcher needs to be run as root so that it can create network links and
Expand Down Expand Up @@ -105,8 +105,8 @@ Usage of ./launcher:
If non-empty, write log files in this directory
-logtostderr
log to standard error instead of files
-network value
Can be none, cn (compute node) or nn (network node) (default none)
-network
Enable networking (default true)
-simulation
Launcher simulation
-stderrthreshold value
Expand Down Expand Up @@ -273,7 +273,7 @@ ciao-launcher-server.

Open a new terminal and start ciao-launcher, e.g.,

./ciao-launcher --logtostderr --network cn
./ciao-launcher --logtostderr

Open a new terminal and try some ciaolc commands

Expand Down
2 changes: 1 addition & 1 deletion ciao-launcher/delete_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func processDelete(vm virtualizer, instanceDir string, conn serverConn, running

_ = vm.deleteImage()

if networking.Enabled() && running != ovsPending {
if networking && running != ovsPending {
glog.Info("Deleting Vnic")
deleteVnic(instanceDir, conn)
}
Expand Down
1 change: 1 addition & 0 deletions ciao-launcher/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ func TestStopNotRunning(t *testing.T) {
}

func startVMWithCFG(t *testing.T, wg *sync.WaitGroup, cfg *vmConfig, connect bool, errorOk bool) (*instanceTestState, chan interface{}, chan<- interface{}, chan struct{}) {
networking = false
doneCh := make(chan struct{})
ovsCh := make(chan interface{})
state := &instanceTestState{
Expand Down
44 changes: 3 additions & 41 deletions ciao-launcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,6 @@ import (

var profileFN func() func()

type networkFlag string

func (f *networkFlag) String() string {
return string(*f)
}

func (f *networkFlag) Set(val string) error {
if val != "none" && val != "cn" && val != "nn" && val != "dual" {
return fmt.Errorf("none, cn, nn or dual expected")
}
*f = networkFlag(val)

return nil
}

func (f *networkFlag) Enabled() bool {
return string(*f) != "none"
}

func (f *networkFlag) NetworkNode() bool {
return string(*f) == "nn"
}

func (f *networkFlag) DualMode() bool {
return string(*f) == "dual"
}

type uiFlag string

func (f *uiFlag) String() string {
Expand All @@ -86,7 +59,7 @@ var serverCertPath string
var clientCertPath string
var computeNet string
var mgmtNet string
var networking networkFlag = "none"
var networking bool
var hardReset bool
var diskLimit bool
var memLimit bool
Expand All @@ -96,7 +69,7 @@ var maxInstances = int(math.MaxInt32)
func init() {
flag.StringVar(&serverCertPath, "cacert", "", "Client certificate")
flag.StringVar(&clientCertPath, "cert", "", "CA certificate")
flag.Var(&networking, "network", "Can be none, cn (compute node) or nn (network node)")
flag.BoolVar(&networking, "network", true, "Enable networking")
flag.BoolVar(&hardReset, "hard-reset", false, "Kill and delete all instances, reset networking and exit")
flag.BoolVar(&simulate, "simulation", false, "Launcher simulation")
}
Expand Down Expand Up @@ -313,7 +286,7 @@ func processCommand(conn serverConn, cmd *cmdWrapper, ovsCh chan<- interface{})
}

func startNetwork(doneCh chan struct{}) error {
if networking.Enabled() {
if networking {
ctx, cancelFunc := context.WithCancel(context.Background())
ch := initNetworking(ctx)
select {
Expand Down Expand Up @@ -348,17 +321,6 @@ func connectToServer(doneCh chan struct{}, statusCh chan struct{}) {

var wg sync.WaitGroup

var role ssntp.Role
if networking.NetworkNode() {
role = ssntp.NETAGENT
} else if networking.DualMode() {
role = ssntp.AGENT | ssntp.NETAGENT
} else {
role = ssntp.AGENT
}

glog.Infof("Agent Role: %s", role.String())

cfg := &ssntp.Config{CAcert: serverCertPath, Cert: clientCertPath,
Log: ssntp.Log}
client := &agentClient{
Expand Down
2 changes: 1 addition & 1 deletion ciao-launcher/restart_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func processRestart(instanceDir string, vm virtualizer, conn serverConn, cfg *vm
var vnicCfg *libsnnet.VnicConfig
var err error

if networking.Enabled() {
if networking {
vnicCfg, err = createVnicCfg(cfg)
if err != nil {
glog.Errorf("Could not create VnicCFG: %s", err)
Expand Down
2 changes: 1 addition & 1 deletion ciao-launcher/start_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func processStart(cmd *insStartCmd, instanceDir string, vm virtualizer, conn ser
return nil, &startError{err, payloads.InvalidData}
}

if networking.Enabled() {
if networking {
vnicCfg, err = createVnicCfg(cfg)
if err != nil {
glog.Errorf("Could not create VnicCFG: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions testutil/singlevm/run_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ default_if=$(ip route list | awk '/^default/ {print $5}')
default_subnet=$(ip -o -f inet addr show $default_if | awk '{print $4}')

#Cleanup artifacts
sudo "$GOPATH"/bin/ciao-launcher --cacert=./CAcert-"$ciao_host".pem --cert=./cert-CNAgent-NetworkingAgent-"$ciao_host".pem --alsologtostderr -v 3 --hard-reset --network=dual
sudo "$GOPATH"/bin/ciao-launcher --cacert=./CAcert-"$ciao_host".pem --cert=./cert-CNAgent-NetworkingAgent-"$ciao_host".pem --alsologtostderr -v 3 --hard-reset

#Cleanup any prior docker instances and networks
sudo docker rm $(sudo docker ps -qa)
sudo docker network rm $(sudo docker network ls -q -f "type=custom")
sudo rm -f /var/lib/ciao/networking/docker_plugin.db

#Run launcher
sudo "$GOPATH"/bin/ciao-launcher --cacert=./CAcert-"$ciao_host".pem --cert=./cert-CNAgent-NetworkingAgent-"$ciao_host".pem -v 3 --network=dual &
sudo "$GOPATH"/bin/ciao-launcher --cacert=./CAcert-"$ciao_host".pem --cert=./cert-CNAgent-NetworkingAgent-"$ciao_host".pem -v 3 &

0 comments on commit b68ed47

Please sign in to comment.