dockermap.map.action package

Submodules

dockermap.map.action.base module

class dockermap.map.action.base.AbstractActionGenerator(policy, kwargs)

Bases: dockermap.map.policy.PolicyUtil

Abstract base class for action generators, which determine what actions are to be executed based on current container states.

get_state_actions(state, **kwargs)

Generates actions from a single configuration state.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []

dockermap.map.action.resume module

class dockermap.map.action.resume.ResumeActionGenerator(*args, **kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Attached containers are created and prepared, if they are missing. They are re-created if they have terminated with errors. Instance containers are created if missing, started if stopped, and re-created / started if an attached container has been missing.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []

dockermap.map.action.script module

class dockermap.map.action.script.ScriptActionGenerator(*args, **kwargs)

Bases: dockermap.map.action.resume.ResumeActionGenerator

get_state_actions(state, **kwargs)

For dependent items, inherits the behavior from dockermap.map.action.resume.ResumeActionGenerator. For other the main container, checks if containers exist, and depending on the remove_existing_before option either fails or removes them. Otherwise runs the script.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = [u'remove_existing_before']
remove_existing_before = False

dockermap.map.action.simple module

class dockermap.map.action.simple.CreateActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Creates all missing containers, networks, and volumes.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []
class dockermap.map.action.simple.ImagePullActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)
policy_options = [u'pull_all_images', u'pull_insecure_regsitry']
pull_all_images = True
pull_insecure_registry = False
class dockermap.map.action.simple.RemoveActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Removes containers that are stopped. Optionally skips persistent containers. Attached containers are skipped by default from removal but can optionally be included.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = [u'remove_persistent', u'remove_attached']
remove_attached = False
remove_persistent = True
class dockermap.map.action.simple.RestartActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Restarts instance containers.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = [u'restart_exec_commands']
restart_exec_commands = False
class dockermap.map.action.simple.ShutdownActionGenerator(policy, kwargs)

Bases: dockermap.map.action.simple.RemoveActionGenerator

get_state_actions(state, **kwargs)

A combination of StopActionGenerator and RemoveActionGenerator - stops and removes containers where appropriate.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = [u'remove_persistent', u'remove_attached']
class dockermap.map.action.simple.SignalActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Sends kill signals to running containers.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []
class dockermap.map.action.simple.StartActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Generally starts containers that are not running. Attached containers are skipped unless they are initial. Attached containers are also prepared with permissions. Where applicable, exec commands are run in started instance containers.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []
class dockermap.map.action.simple.StartupActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

A combination of CreateActionGenerator and StartActionGenerator - creates and starts containers where appropriate.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []
class dockermap.map.action.simple.StopActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

Stops containers that are running. Does not check attached containers. Considers using the pre-configured stop_signal.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = []

dockermap.map.action.update module

class dockermap.map.action.update.UpdateActionGenerator(policy, kwargs)

Bases: dockermap.map.action.base.AbstractActionGenerator

get_state_actions(state, **kwargs)

For attached volumes, missing containers are created and initial containers are started and prepared with permissions. Outdated containers or containers with errors are recreated. The latter also applies to instance containers. Similarly, instance containers are created if missing and started unless not initial and marked as persistent. On running instance containers missing exec commands are run; if the container needs to be started, all exec commands are launched.

Parameters:
Returns:

Actions on the client, map, and configurations.

Return type:

list[dockermap.map.action.ItemAction]

policy_options = [u'pull_before_update', u'pull_insecure_registry']
pull_before_update = False
pull_insecure_registry = False

Module contents

class dockermap.map.action.Action

Bases: dockermap.map.action.ActionEnum

CONNECT = u'connect'
CREATE = u'create'
DISCONNECT = u'disconnect'
KILL = u'kill'
REMOVE = u'remove'
RESTART = u'restart'
START = u'start'
STOP = u'stop'
UPDATE = u'update'
WAIT = u'wait'
class dockermap.map.action.ActionEnum

Bases: dockermap.map.SimpleEnum

class dockermap.map.action.ContainerUtilAction

Bases: dockermap.map.action.ActionEnum

CONNECT_ALL = u'connect_all_networks'
EXEC_ALL = u'exec_all_commands'
EXEC_COMMANDS = u'exec_single_command'
SCRIPT = u'script'
SIGNAL_STOP = u'signal_stop'
class dockermap.map.action.DerivedAction

Bases: object

RELAUNCH_CONTAINER = [Action.REMOVE, Action.CREATE, ContainerUtilAction.CONNECT_ALL, Action.START]
RESET_CONTAINER = [ContainerUtilAction.SIGNAL_STOP, Action.REMOVE, Action.CREATE, ContainerUtilAction.CONNECT_ALL, Action.START]
RESET_NETWORK = [Action.REMOVE, Action.CREATE]
RESET_VOLUME = [Action.REMOVE, Action.CREATE]
RESTART_CONTAINER = [ContainerUtilAction.SIGNAL_STOP, Action.START]
SHUTDOWN_CONTAINER = [ContainerUtilAction.SIGNAL_STOP, Action.REMOVE]
STARTUP_CONTAINER = [Action.CREATE, ContainerUtilAction.CONNECT_ALL, Action.START]
class dockermap.map.action.ImageAction

Bases: dockermap.map.action.ActionEnum

PULL = u'pull_image'
class dockermap.map.action.ItemAction(state, action_types=None, extra_data=None, **kwargs)

Bases: object

Utility class for storing actions.

Parameters:
  • client_name (unicode | str) – Client configuration name.
  • config_id (dockermap.map.input.MapConfigId) – Configuration id tuple.
  • action_types (unicode | str | list[unicode | str] | tuple[unicode | str]) – Action type name(s) to perform. Input is converted to a list.
  • extra_data (dict) – Extra data. Typically passed on as keyword arguments to the client function.
  • kwargs – Additional keyword arguments; added to extra_data
action_types

Action type name(s) to perform. Input is converted to a list.

Returns:Action type(s).
Return type:list[unicode | str]
client_name

Name of the client configuration affected by this action.

Returns:Client configuration name.
Return type:unicode | str
config_id

The map configuration id of the affected configuration.

Returns:Configuration id.
Return type:dockermap.map.input.MapConfigId
extra_data

Extra data. Typically passed on as keyword arguments to the client function.

Returns:Dictionary with extra data.
Return type:dict
class dockermap.map.action.NetworkUtilAction

Bases: dockermap.map.action.ActionEnum

DISCONNECT_ALL = u'disconnect_all_containers'
class dockermap.map.action.VolumeUtilAction

Bases: dockermap.map.action.ActionEnum

PREPARE = u'prepare_volume'