func (c *ComputeUtil) openFirewallPorts(d *Driver) error {
	log.Infof("Opening firewall ports")

	create := false
	rule, _ := c.firewallRule()
	if rule == nil {
		create = true
		rule = &raw.Firewall{
			Name:         firewallRule,
			Allowed:      []*raw.FirewallAllowed{},
			SourceRanges: []string{"0.0.0.0/0"},
			TargetTags:   []string{firewallTargetTag},
			Network:      c.globalURL + "/networks/" + d.Network,
		}
	}

	portsUsed, err := c.portsUsed()
	if err != nil {
		return err
	}

	missingPorts := missingOpenedPorts(rule, portsUsed)
	if len(missingPorts) == 0 {
		return nil
	}
	for proto, ports := range missingPorts {
		rule.Allowed = append(rule.Allowed, &raw.FirewallAllowed{
			IPProtocol: proto,
			Ports:      ports,
		})
	}

	var op *raw.Operation
	if create {
		op, err = c.service.Firewalls.Insert(c.project, rule).Do()
	} else {
		op, err = c.service.Firewalls.Update(c.project, firewallRule, rule).Do()
	}

	if err != nil {
		return err
	}

	return c.waitForGlobalOp(op.Name)
}
func (c *ComputeUtil) openFirewallPorts(d *Driver) error {
	log.Infof("Opening firewall ports")

	create := false
	rule, _ := c.firewallRule()
	if rule == nil {
		create = true
		rule = &raw.Firewall{
			Name:         firewallRule,
			Allowed:      []*raw.FirewallAllowed{},
			SourceRanges: []string{"0.0.0.0/0"},
			TargetTags:   []string{firewallTargetTag},
			Network:      c.globalURL + "/networks/" + d.Network,
		}
	}

	portsUsed, err := c.portsUsed()
	if err != nil {
		return err
	}

	missingPorts := missingOpenedPorts(rule, portsUsed)
	if len(missingPorts) == 0 {
		return nil
	}
	for proto, ports := range missingPorts {
		rule.Allowed = append(rule.Allowed, &raw.FirewallAllowed{
			IPProtocol: proto,
			Ports:      ports,
		})
	}

	var op *raw.Operation
	if create {
		op, err = c.service.Firewalls.Insert(c.project, rule).Do()
	} else {
		op, err = c.service.Firewalls.Update(c.project, firewallRule, rule).Do()
	}

	if err != nil {
		return err
	}

	return c.waitForGlobalOp(op.Name)
}
func ( c * ComputeUtil ) openFirewallPorts ( d * Driver ) error { log . Infof ( " " ) create := false rule , _ := c . firewallRule ( ) if rule == nil { create = true rule = & raw . Firewall { Name : firewallRule , Allowed : [ ] * raw . FirewallAllowed { } , SourceRanges : [ ] string { " " } , TargetTags : [ ] string { firewallTargetTag } , Network : c . globalURL + " " + d . Network , } } portsUsed , err := c . portsUsed ( ) if err != nil { return err } missingPorts := missingOpenedPorts ( rule , portsUsed ) if len ( missingPorts ) == 0 { return nil } for proto , ports := range missingPorts { rule . Allowed = append ( rule . Allowed , & raw . FirewallAllowed { IPProtocol : proto , Ports : ports , } ) } var op * raw . Operation if create { op , err = c . service . Firewalls . Insert ( c . project , rule ) . Do ( ) } else { op , err = c . service . Firewalls . Update ( c . project , firewallRule , rule ) . Do ( ) } if err != nil { return err } return c . waitForGlobalOp ( op . Name ) }
// openFirewallPorts configures the firewall to open docker and swarm ports.
openFirewallPorts configures the firewall to open docker and swarm ports .