Environment Class
Model a single Environment. Serves as a place to collect Environment level annotations.
Item Index
Methods
- _modelToObject
- alive
- annotationInfo
- cleanUpEntityTags
- convertOpenPorts
- createDisplayName
- createDisplayName
- createEndpoints
- getAnnotations
- getEndpoints
- getEndpoints.add
- getEndpoints.convert
- getModelListByModelName
- hasErrors
- isAlive
- machineInfo
- onDelta
- process_delta
- pyDelta
- relationInfo
- resolveModelByName
- serviceInfo
- unitInfo
Methods
_modelToObject
-
model
Overrides the LazyModelList method to force an id attribute on. LazyModelList wants an "id" to index on. It's not configurable.
Parameters:
-
modelModel | ObjectModel instance to convert.
Returns:
alive
()
Y.ModelList
Return a list of visible model instances.
A model instance is visible when it is alive or when, even if it is dying or dead, one or more of its units are in an error state. In the latter case, we want to still display the service in order to allow users to retry or resolve its units.
Returns:
annotationInfo
-
db -
action -
change -
kind
Handle annotation info coming from the juju-core delta, updating the relevant database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
Returns:
cleanUpEntityTags
-
tag
Clean up the entity tags, which have the entity type prefixing the entity's name when retrieved from the server in some instances, notably annotations.
The regular expression removes any non-hyphen characters followed by a hyphen from the beginning of a string. Thus, service-mysql becomes simply mysql (as the expression matches 'service-'). This function also converts the unit tag so that "unit-mysql-1" becomes "mysql/1".
Parameters:
-
tagStringThe tag to clean up.
Returns:
convertOpenPorts
-
ports
Return a list of ports represented as "NUM/PROTOCOL", e.g. "80/tcp".
Parameters:
-
portsArrayA list of port objects, each one including the "Number" and "Protocol" attributes.
Returns:
createDisplayName
-
name
Create a display name that can be used in the views as an entity label agnostic from juju type.
Parameters:
-
nameStringThe name to modify.
Returns:
createDisplayName
-
name
Create a display name that can be used in the views as an entity label agnostic from juju type.
Parameters:
-
nameStringThe name to modify.
Returns:
createEndpoints
-
endpoints
Return a list of endpoints suitable for being included in the database.
Parameters:
-
endpointsArrayA list of endpoints returned by the juju-core delta stream.
Returns:
getAnnotations
-
Model
Get annotations for an entity.
Parameters:
-
ModelObject(or ModelList managed object).
Returns:
getEndpoints
-
svc -
controller
Find available relation targets for a service.
Parameters:
-
svcObjectA service object.
-
controllerObjectThe endpoints controller.
Returns:
getEndpoints.add
-
tep -
oep
Store endpoints for a relation to target the given service.
Parameters:
-
tepObjectTarget endpoint.
-
oepObjectOrigin endpoint.
getEndpoints.convert
()
Convert a service name and its relation endpoint info into a valid relation target endpoint, ie. including service name.
getModelListByModelName
-
modelName
Returns a modelList given the model name.
Parameters:
-
modelNameStringThe model's name.
Returns:
hasErrors
()
Boolean
Return true if one or more units in this service are in an error state.
Return false otherwise.
Returns:
isAlive
()
Boolean
Return true if this service life is "alive", false otherwise.
A model instance is alive if its life cycle (i.e. the "life" attribute) is set to "alive". Other possible values, as they arrive from the juju-core delta stream, are "dying" and "dead", in which cases the service is not considered alive.
Returns:
machineInfo
-
db -
action -
change -
kind
Handle machine info coming from the juju-core delta, updating the relevant database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
Returns:
onDelta
-
deltaEvent
Handle the delta stream coming from the API backend. Populate the database according to the changeset included in the delta.
Parameters:
-
deltaEventEventAn event object containing the delta changeset (in the "data.result" attribute).
Returns:
process_delta
()
Update the annotations on delta events. We don't support removal of the Environment model.
pyDelta
-
db -
action -
change -
kind
Convert the delta stream coming from pyJuju into that suitable for being used by the database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
Returns:
relationInfo
-
db -
action -
change -
kind
Handle relation info coming from the juju-core delta, updating the relevant database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
Returns:
resolveModelByName
-
Entity
Resolve from an id to a Database entity. The lookup pattern is such that
"env" -> environment model
Parameters:
-
EntityObjectname, usually {String}, {Int} possible for machine.
Returns:
serviceInfo
-
db -
action -
change -
kind
Handle service info coming from the juju-core delta, updating the relevant database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
Returns:
unitInfo
-
db -
action -
change -
kind
Handle unit info coming from the juju-core delta, updating the relevant database models.
Parameters:
-
dbObjectThe app.models.models.Database instance.
-
actionStringThe operation to be performed ("add", "change" or "remove").
-
changeObjectThe JSON entity information.
-
kindStringThe delta event type.
