コード例 #1
0
ファイル: remote.go プロジェクト: AlexisBruemmer/juju
// UsingTCP converts the remote into a non-local version. For
// non-local remotes this is a no-op.
//
// For a "local" remote (see Local), the remote is changed to a one
// with the host set to the IP address of the local lxcbr0 bridge
// interface. The remote is also set up for remote access, setting
// the cert if not already set.
func (r Remote) UsingTCP() (Remote, error) {
	// Note that r is a value receiver, so it is an implicit copy.

	if !r.isLocal() {
		return r, nil
	}

	// TODO: jam 2016-02-25 This should be updated for systems that are
	// 	 space aware, as we may not be just using the default LXC
	// 	 bridge.
	netIF, err := GetDefaultBridgeName()
	if err != nil {
		return r, errors.Trace(err)
	}
	addr, err := utils.GetAddressForInterface(netIF)
	if err != nil {
		return r, errors.Trace(err)
	}
	r.Host = addr

	r, err = r.WithDefaults()
	if err != nil {
		return r, errors.Trace(err)
	}

	// TODO(ericsnow) Change r.Name if "local"? Prepend "juju-"?

	return r, nil
}
コード例 #2
0
ファイル: remote.go プロジェクト: imoapps/juju
// UsingTCP converts the remote into a non-local version. For
// non-local remotes this is a no-op.
//
// For a "local" remote (see Local), the remote is changed to a one
// with the host set to the IP address of the local lxcbr0 bridge
// interface. The remote is also set up for remote access, setting
// the cert if not already set.
func (r Remote) UsingTCP() (Remote, error) {
	// Note that r is a value receiver, so it is an implicit copy.

	if !r.isLocal() {
		return r, nil
	}

	netIF := lxc.DefaultLxcBridge
	addr, err := utils.GetAddressForInterface(netIF)
	if err != nil {
		return r, errors.Trace(err)
	}
	r.Host = addr

	r, err = r.WithDefaults()
	if err != nil {
		return r, errors.Trace(err)
	}

	// TODO(ericsnow) Change r.Name if "local"? Prepend "juju-"?

	return r, nil
}