~juju-qa/ubuntu/yakkety/juju/juju-1.25.8

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/provider/gce/environ_network.go

  • Committer: Nicholas Skaggs
  • Date: 2016-12-02 17:28:37 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161202172837-jkrbdlyjcxtrii2n
Initial commit of 1.25.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package gce
 
5
 
 
6
import (
 
7
        "github.com/juju/errors"
 
8
 
 
9
        "github.com/juju/juju/network"
 
10
        "github.com/juju/juju/provider/common"
 
11
)
 
12
 
 
13
// globalFirewallName returns the name to use for the global firewall.
 
14
func (env *environ) globalFirewallName() string {
 
15
        return common.EnvFullName(env)
 
16
}
 
17
 
 
18
// OpenPorts opens the given port ranges for the whole environment.
 
19
// Must only be used if the environment was setup with the
 
20
// FwGlobal firewall mode.
 
21
func (env *environ) OpenPorts(ports []network.PortRange) error {
 
22
        err := env.gce.OpenPorts(env.globalFirewallName(), ports...)
 
23
        return errors.Trace(err)
 
24
}
 
25
 
 
26
// ClosePorts closes the given port ranges for the whole environment.
 
27
// Must only be used if the environment was setup with the
 
28
// FwGlobal firewall mode.
 
29
func (env *environ) ClosePorts(ports []network.PortRange) error {
 
30
        err := env.gce.ClosePorts(env.globalFirewallName(), ports...)
 
31
        return errors.Trace(err)
 
32
}
 
33
 
 
34
// Ports returns the port ranges opened for the whole environment.
 
35
// Must only be used if the environment was setup with the
 
36
// FwGlobal firewall mode.
 
37
func (env *environ) Ports() ([]network.PortRange, error) {
 
38
        ports, err := env.gce.Ports(env.globalFirewallName())
 
39
        return ports, errors.Trace(err)
 
40
}