Exemplo n.º 1
0
Arquivo: pinger.go Projeto: bac/juju
// NewPinger returns an object that can be pinged by calling its Ping method.
// If this method is not called frequently enough, the connection will be
// dropped.
func NewPinger(st *state.State, resources facade.Resources, authorizer facade.Authorizer) (Pinger, error) {
	pingTimeout, ok := resources.Get("pingTimeout").(*pingTimeout)
	if !ok {
		return nullPinger{}, nil
	}
	return pingTimeout, nil
}
Exemplo n.º 2
0
Arquivo: backups.go Projeto: bac/juju
func extractResourceValue(resources facade.Resources, key string) (string, error) {
	res := resources.Get(key)
	strRes, ok := res.(common.StringResource)
	if !ok {
		if res == nil {
			strRes = ""
		} else {
			return "", errors.Errorf("invalid %s resource: %v", key, res)
		}
	}
	return strRes.String(), nil
}
Exemplo n.º 3
0
Arquivo: watcher.go Projeto: bac/juju
func newMachineStorageIdsWatcher(
	st *state.State,
	resources facade.Resources,
	auth facade.Authorizer,
	id string,
	parser func([]string) ([]params.MachineStorageId, error),
) (facade.Facade, error) {
	if !isAgent(auth) {
		return nil, common.ErrPerm
	}
	watcher, ok := resources.Get(id).(state.StringsWatcher)
	if !ok {
		return nil, common.ErrUnknownWatcher
	}
	return &srvMachineStorageIdsWatcher{watcher, id, resources, parser}, nil
}