~ubuntu-branches/ubuntu/saucy/juju-core/saucy

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/worker/firewaller/firewaller.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 16:02:16 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130820160216-5yu1llasa2e2youn
Tags: 1.13.1-0ubuntu1
* New upstream release.
  - Build and install juju metadata plugin.
  - d/NEWS: Add some guidance on upgrading environments from 1.11.x
    to 1.13.x.
* d/NEWS: Add details about lack of upgrade path from juju < 1.11
  and how to interact with older juju environments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
                        }
119
119
                }
120
120
        }
121
 
        panic("not reached")
122
121
}
123
122
 
124
123
// stop a watcher with logging of a possible error.
236
235
                wantedPorts = append(wantedPorts, port)
237
236
        }
238
237
        // Check which ports to open or to close.
239
 
        toOpen := diff(wantedPorts, initialPorts)
240
 
        toClose := diff(initialPorts, wantedPorts)
 
238
        toOpen := Diff(wantedPorts, initialPorts)
 
239
        toClose := Diff(initialPorts, wantedPorts)
241
240
        if len(toOpen) > 0 {
242
241
                log.Infof("worker/firewaller: opening global ports %v", toOpen)
243
242
                if err := fw.environ.OpenPorts(toOpen); err != nil {
284
283
                        return err
285
284
                }
286
285
                // Check which ports to open or to close.
287
 
                toOpen := diff(machined.ports, initialPorts)
288
 
                toClose := diff(initialPorts, machined.ports)
 
286
                toOpen := Diff(machined.ports, initialPorts)
 
287
                toClose := Diff(initialPorts, machined.ports)
289
288
                if len(toOpen) > 0 {
290
289
                        log.Infof("worker/firewaller: opening instance ports %v for machine %s",
291
290
                                toOpen, machined.id)
376
375
        for port := range ports {
377
376
                want = append(want, port)
378
377
        }
379
 
        toOpen := diff(want, machined.ports)
380
 
        toClose := diff(machined.ports, want)
 
378
        toOpen := Diff(want, machined.ports)
 
379
        toClose := Diff(machined.ports, want)
381
380
        machined.ports = want
382
381
        if fw.globalMode {
383
382
                return fw.flushGlobalPorts(toOpen, toClose)
745
744
        return sd.tomb.Wait()
746
745
}
747
746
 
748
 
// diff returns all the ports that exist in A but not B.
749
 
func diff(A, B []instance.Port) (missing []instance.Port) {
 
747
// Diff returns all the ports that exist in A but not B.
 
748
func Diff(A, B []instance.Port) (missing []instance.Port) {
750
749
next:
751
750
        for _, a := range A {
752
751
                for _, b := range B {