FakeBackend Class
An in-memory fake Juju backend.
Item Index
Methods
- _getAnnotationGroup
- _getAvailableMachines
- _getCharmFromData
- _getUnitMachines
- _loadCharm
- _resetAnnotations
- _resetChanges
- addRelation
- addUnit
- deploy
- destroyService
- expose
- findMatch
- getAnnotations
- getCharm
- getService
- initializer
- login
- newEnvironment static
- nextAnnotations
- nextChanges
- parseEndpointStrings
- removeAnnotations
- removeRelation
- removeUnits
- resolved
- setConfig
- setConstraints
- unexpose
- updateAnnotations
Methods
_getAnnotationGroup
-
entity
Helper method to determine where to log annotation changes relative to a given entity.
Parameters:
-
entityObjectto track.
Returns:
_getAvailableMachines
()
Array
Find machines without any units currently assigned.
Returns:
_getCharmFromData
-
data
Convert charm data as returned by the charmStore into a charm. The charm might be pre-existing or might need to be created, but after this method it will be within the db.
Parameters:
-
dataObjectThe raw charm information as delivered by the charmStore's loadByPath method.
Returns:
_getUnitMachines
-
count
Find or allocate machines for the requested number of units.
Parameters:
-
countIntegerThe number of units that need machines.
Returns:
_loadCharm
-
charmUrl -
callbacks
Get a charm from a URL, via charmStore and/or db. Uses callbacks.
Parameters:
-
charmUrlStringThe URL of the charm.
-
callbacksFunctionAn optional object with optional success and failure callables. This is asynchronous because we often must go over the network to the charm store. The success callable receives the fully loaded charm, and the failure callable receives an object with an explanatory "error" attribute.
Returns:
_resetAnnotations
()
Undefined
Reset the database for reporting object annotation changes.
Returns:
_resetChanges
()
Undefined
Reset the database for reporting object changes.
Returns:
addRelation
-
endpointA -
endpointB
Add a relation between two services.
Parameters:
-
endpointAStringA string representation of the service name and endpoint connection type ie) wordpress:db.
-
endpointBStringA string representation of the service name and endpoint connection type ie) wordpress:db.
addUnit
-
serviceName -
numUnits
Add units to the given service.
Parameters:
-
serviceNameStringThe name of the service to be scaled up.
-
numUnitsIntegerThe number of units to be added, defaulting to 1.
Returns:
deploy
-
charmUrl -
callback -
options
Deploy a charm. Uses a callback for response!
Parameters:
-
charmUrlStringThe URL of the charm.
-
callbackFunctionA call that will receive an object either with an "error" attribute containing a string describing the problem, or with a "service" attribute containing the new service, a "charm" attribute containing the charm used, and a "units" attribute containing a list of the added units. This is asynchronous because we often must go over the network to the charm store.
-
optionsObjectAn options object. name: The name of the service to be deployed, defaulting to the charm name. config: The charm configuration options, defaulting to none. configYAML: The charm configuration options, expressed as a YAML string. You may provide only one of config or configYAML. unitCount: The number of units to be deployed.
Returns:
destroyService
-
serviceName
Destroy the named service.
Parameters:
-
serviceNameStringto destroy.
Returns:
expose
-
serviceName
Exposes a service from the supplied string.
Parameters:
-
serviceNameStringThe service name.
Returns:
error and warning properties
which will be undefined if there were no warnings or errors.
findMatch
-
endpoints
Loops through the charm endpoint data to determine whether we have a relationship match. The result is either an object with an error attribute, or an object giving the interface, scope, providing endpoint, and requiring endpoint.
Parameters:
-
endpointsArrayPair of two endpoint data objects. Each endpoint data object has name, charm, service, and scope.
Returns:
getAnnotations
-
entityName
getAnnotations from an object. This uses standard name resolution (see db.resolveModelByName) to determine which object to return annotations for.
Parameters:
-
entityNameStringto get annotations for.
Returns:
getCharm
-
charmName
Get Charm data.
Parameters:
-
charmNameStringto get.
Returns:
getService
-
serviceName
Get service attributes.
Parameters:
-
serviceNameStringto get.
Returns:
initializer
()
Undefined
Initializes.
Returns:
login
-
username -
submittedPassword
Attempt to log a user in.
Parameters:
-
usernameStringThe id of the user.
-
submittedPasswordStringThe user-submitted password.
Returns:
newEnvironment
-
options -
apiBackend
Create and return a store environment suitable for connecting to the provided API backend.
Parameters:
-
optionsObjectAttributes used for instantiating the environment.
-
apiBackendStringThe name of the API backend this environment connects to.
Returns:
nextAnnotations
()
Object
Return all of the recently anotated objects.
Returns:
nextChanges
()
Object
Return all of the recently changed objects.
Returns:
parseEndpointStrings
-
endpoints
Takes two string endpoints and splits it into usable parts.
Parameters:
-
endpointsArrayan array of endpoint strings to split in the format wordpress:db.
Returns:
removeAnnotations
-
entityName -
keys
Remove annotations (optional by key) from an entity.
Parameters:
-
entityNameStringto remove annotations from.
-
keysArray(optional) array of {String} keys to remove. If this is falsey all annotations are removed.
Returns:
removeRelation
-
endpointA -
endpointB
Removes a relation between two services.
Parameters:
-
endpointAStringA string representation of the service name and endpoint connection type ie) wordpress:db.
-
endpointBStringA string representation of the service name and endpoint connection type ie) wordpress:db.
removeUnits
-
unitNames
Removes the supplied units
Parameters:
-
unitNamesArraya list of unit names to be removed.
resolved
-
unitName -
(optional)
Mark a unit or a unit relation as resolved. In the fakebackend this validates arguments but doesn't take any real action.
Parameters:
-
unitNameStringtp resp;ve.
-
(optional)StringrelationName to resolve for unit.
Returns:
setConfig
-
serviceName -
config
Sets the configuration settings on the supplied service to the supplied config object while leaving the settings untouched if they are not in the supplied config.
Parameters:
-
serviceNameStringthe service id.
-
configObjectproperties to set.
setConstraints
-
serviceName -
data
Sets the constraints on a service to restrict the type of machine to be used for the service.
Parameters:
-
serviceNameStringthe service id.
-
dataObject | Arrayeither an array of strings "foo=bar" or an object {foo: 'bar'}.
unexpose
-
serviceName
Unexposes a service from the supplied string.
Parameters:
-
serviceNameStringThe service name.
Returns:
error and warning properties
which will be undefined if there were no warnings or errors.
updateAnnotations
-
entityName -
annotations
Update annotations for a given entity. This performs a merge of existing annotations with any new data.
Parameters:
-
entityNameStringto update.
-
annotationsObjectkey/value map.
