Exemplo n.º 1
0
// NewState creates a new client-side Machiner facade.
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, provisionerFacade)
	return &State{
		ModelWatcher: common.NewModelWatcher(facadeCaller),
		APIAddresser: common.NewAPIAddresser(facadeCaller),
		facade:       facadeCaller}
}
Exemplo n.º 2
0
// newStateForVersion creates a new client-side Uniter facade for the
// given version.
func newStateForVersion(
	caller base.APICaller,
	authTag names.UnitTag,
	version int,
) *State {
	facadeCaller := base.NewFacadeCallerForVersion(
		caller,
		uniterFacade,
		version,
	)
	state := &State{
		ModelWatcher:    common.NewModelWatcher(facadeCaller),
		APIAddresser:    common.NewAPIAddresser(facadeCaller),
		StorageAccessor: NewStorageAccessor(facadeCaller),
		facade:          facadeCaller,
		unitTag:         authTag,
	}

	newWatcher := func(result params.NotifyWatchResult) watcher.NotifyWatcher {
		return apiwatcher.NewNotifyWatcher(caller, result)
	}
	state.LeadershipSettings = NewLeadershipSettingsAccessor(
		facadeCaller.FacadeCall,
		newWatcher,
		ErrIfNotVersionFn(2, state.BestAPIVersion()),
	)
	return state
}
Exemplo n.º 3
0
// NewState creates a new client-side Firewaller API facade.
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, firewallerFacade)
	return &State{
		facade:       facadeCaller,
		ModelWatcher: common.NewModelWatcher(facadeCaller),
	}
}
Exemplo n.º 4
0
Arquivo: state.go Projeto: bac/juju
// NewState returns a version of the state that provides functionality
// required by agent code.
func NewState(caller base.APICaller) *State {
	facadeCaller := base.NewFacadeCaller(caller, "Agent")
	return &State{
		facade:              facadeCaller,
		ModelWatcher:        common.NewModelWatcher(facadeCaller),
		CloudSpecAPI:        cloudspec.NewCloudSpecAPI(facadeCaller),
		ControllerConfigAPI: common.NewControllerConfig(facadeCaller),
	}
}
Exemplo n.º 5
0
// NewAPI creates a new client-side InstancePoller facade.
func NewAPI(caller base.APICaller) *API {
	if caller == nil {
		panic("caller is nil")
	}
	facadeCaller := base.NewFacadeCaller(caller, instancePollerFacade)
	return &API{
		ModelWatcher: common.NewModelWatcher(facadeCaller),
		facade:       facadeCaller,
	}
}
Exemplo n.º 6
0
// NewState creates a new client-side StorageProvisioner facade.
func NewState(caller base.APICaller, scope names.Tag) (*State, error) {
	switch scope.(type) {
	case names.ModelTag:
	case names.MachineTag:
	default:
		return nil, errors.Errorf("expected ModelTag or MachineTag, got %T", scope)
	}
	facadeCaller := base.NewFacadeCaller(caller, storageProvisionerFacade)
	return &State{
		facadeCaller,
		scope,
		common.NewModelWatcher(facadeCaller),
	}, nil
}
Exemplo n.º 7
0
// NewFacade returns a new api client facade instance.
func NewFacade(caller base.APICaller) *Facade {
	facadeCaller := base.NewFacadeCaller(caller, apiName)
	return &Facade{
		ModelWatcher: common.NewModelWatcher(facadeCaller),
	}
}