API Docs for:
Show:

Environment Class

Module: models

Model a single Environment. Serves as a place to collect Environment level annotations.

Methods

_modelToObject

(
  • model
)
Object protected

Overrides the LazyModelList method to force an id attribute on. LazyModelList wants an "id" to index on. It's not configurable.

Parameters:

  • model Model | Object

    Model instance to convert.

Returns:

Object: Plain object.

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:

Y.ModelList: The resulting visible model instances.

annotationInfo

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:222

Handle annotation info coming from the juju-core delta, updating the relevant database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.

cleanUpEntityTags

(
  • tag
)
String

Provided by the handlers module.

Defined in app/models/handlers.js:19

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:

  • tag String

    The tag to clean up.

Returns:

String: The tag without the prefix.

convertOpenPorts

(
  • ports
)
Array

Provided by the handlers module.

Defined in app/models/handlers.js:46

Return a list of ports represented as "NUM/PROTOCOL", e.g. "80/tcp".

Parameters:

  • ports Array

    A list of port objects, each one including the "Number" and "Protocol" attributes.

Returns:

Array: The converted list of ports.

createDisplayName

(
  • name
)
String

Create a display name that can be used in the views as an entity label agnostic from juju type.

Parameters:

  • name String

    The name to modify.

Returns:

String: A display name.

createDisplayName

(
  • name
)
String

Create a display name that can be used in the views as an entity label agnostic from juju type.

Parameters:

  • name String

    The name to modify.

Returns:

String: A display name.

createEndpoints

(
  • endpoints
)
Array

Provided by the handlers module.

Defined in app/models/handlers.js:63

Return a list of endpoints suitable for being included in the database.

Parameters:

  • endpoints Array

    A list of endpoints returned by the juju-core delta stream.

Returns:

Array: The converted list of endpoints.

getAnnotations

(
  • Model
)
Object

Get annotations for an entity.

Parameters:

  • Model Object

    (or ModelList managed object).

Returns:

Object: Annotations.

getEndpoints

(
  • svc
  • controller
)
Object

Provided by the models.endpoints module.

Defined in app/models/endpoints.js:15

Find available relation targets for a service.

Parameters:

  • svc Object

    A service object.

  • controller Object

    The endpoints controller.

Returns:

Object: A mapping with keys of valid relation service targets and values consisting of a list of valid endpoints for each.

getEndpoints.add

(
  • tep
  • oep
)

Provided by the models.endpoints module.

Defined in app/models/endpoints.js:47

Store endpoints for a relation to target the given service.

Parameters:

  • tep Object

    Target endpoint.

  • oep Object

    Origin endpoint.

getEndpoints.convert

()

Provided by the models.endpoints module.

Defined in app/models/endpoints.js:33

Convert a service name and its relation endpoint info into a valid relation target endpoint, ie. including service name.

getModelListByModelName

(
  • modelName
)
Object

Returns a modelList given the model name.

Parameters:

  • modelName String

    The model's name.

Returns:

Object: The model list.

hasErrors

() Boolean

Return true if one or more units in this service are in an error state.

Return false otherwise.

Returns:

Boolean: Whether one or more unit are in an error state.

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:

Boolean: Whether this service is alive.

machineInfo

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:200

Handle machine info coming from the juju-core delta, updating the relevant database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.

onDelta

(
  • deltaEvent
)
Undefined

Handle the delta stream coming from the API backend. Populate the database according to the changeset included in the delta.

Parameters:

  • deltaEvent Event

    An event object containing the delta changeset (in the "data.result" attribute).

Returns:

Undefined: Nothing.

process_delta

()

Update the annotations on delta events. We don't support removal of the Environment model.

pyDelta

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:92

Convert the delta stream coming from pyJuju into that suitable for being used by the database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.

relationInfo

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:175

Handle relation info coming from the juju-core delta, updating the relevant database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.

resolveModelByName

(
  • Entity
)
Model

Resolve from an id to a Database entity. The lookup pattern is such that "env" -> environment model -> machine / -> unit -> service

Parameters:

  • Entity Object

    name, usually {String}, {Int} possible for machine.

Returns:

Model: resolved by call.

serviceInfo

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:152

Handle service info coming from the juju-core delta, updating the relevant database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.

unitInfo

(
  • db
  • action
  • change
  • kind
)
Undefined

Provided by the handlers module.

Defined in app/models/handlers.js:121

Handle unit info coming from the juju-core delta, updating the relevant database models.

Parameters:

  • db Object

    The app.models.models.Database instance.

  • action String

    The operation to be performed ("add", "change" or "remove").

  • change Object

    The JSON entity information.

  • kind String

    The delta event type.

Returns:

Undefined: Nothing.