dockermap.map.state package

Submodules

dockermap.map.state.base module

class dockermap.map.state.base.AbstractDependencyStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.AbstractStateGenerator

get_dependency_path(config_id)

To be implemented by subclasses (or using ForwardActionGeneratorMixin or ReverseActionGeneratorMixin). Should provide an iterable of objects to be handled before the explicitly selected container configuration.

Parameters:config_id (dockermap.map.input.MapConfigId) – MapConfigId tuple.
Returns:Iterable of dependency objects in tuples of configuration type, map name, config name, and instance.
Return type:collections.Iterable[dockermap.map.input.MapConfigId]
get_states(config_ids)

Generates state information for the selected container and its dependencies / dependents.

Parameters:config_ids (list[dockermap.map.input.MapConfigId]) – MapConfigId tuples.
Returns:Iterable of configuration states.
Return type:collections.Iterable[dockermap.map.state.ConfigState]
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
class dockermap.map.state.base.AbstractState(policy, options, client_name, config_id, config_flags=ConfigFlags(), *args, **kwargs)

Bases: object

Abstract base implementation for determining the current state of a single object on the client.

Parameters:
get_state()

Determines and returns the state information.

Returns:State information.
Type:tuple
inspect()

Inspects the object on the client, i.e. makes actual calls to the client to check on the object.

set_defaults()

Resets the state, so that with adjustments of input parameters the object can be reused without side-effects to other objects on the client.

class dockermap.map.state.base.AbstractStateGenerator(policy, kwargs)

Bases: dockermap.map.policy.PolicyUtil

Abstract base implementation for an state generator, which determines the current state of containers on the client.

container_state_class

alias of ContainerBaseState

force_update = None
generate_config_states(config_id, config_flags=ConfigFlags())

Generates the actions on a single item, which can be either a dependency or a explicitly selected container.

Parameters:
Returns:

Generator for container state information.

Return type:

collections.Iterable[dockermap.map.state.ContainerConfigStates]

get_container_state(*args, **kwargs)
get_image_state(*args, **kwargs)
get_network_state(*args, **kwargs)
get_states(config_ids)

To be implemented by subclasses. Generates state information for the selected containers.

Parameters:config_ids (list[dockermap.map.input.MapConfigId]) – MapConfigId tuple.
Returns:Iterable of configuration states.
Return type:collections.Iterable[dockermap.map.state.ConfigState]
get_volume_state(*args, **kwargs)
image_state_class

alias of ImageBaseState

network_state_class

alias of NetworkBaseState

nonrecoverable_exit_codes = (-127, -1)
policy

Policy object instance to generate actions for.

Returns:Policy object instance.
Return type:BasePolicy
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
volume_state_class

alias of VolumeBaseState

class dockermap.map.state.base.ContainerBaseState(*args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Base implementation for determining the current state of a single container on the client.

Parameters:
get_state()
inspect()

Fetches information about the container from the client.

set_defaults()
class dockermap.map.state.base.DependencyStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.AbstractDependencyStateGenerator

get_dependency_path(config_id)
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
class dockermap.map.state.base.DependentStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.AbstractDependencyStateGenerator

get_dependency_path(config_id)
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
class dockermap.map.state.base.ImageBaseState(policy, options, client_name, config_id, config_flags=ConfigFlags(), *args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Base implementation for determining the current state of an image. There is no configuration object passed to this inspection. The image name is represented in the config_name of the configuration id, and the tag in instance_name.

get_state()
inspect()

Fetches image information from the client.

class dockermap.map.state.base.ImageDependencyStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.AbstractDependencyStateGenerator

get_dependency_path(config_id)
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
class dockermap.map.state.base.NetworkBaseState(*args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Base implementation for determining the current state of a single network on the client.

Parameters:
get_state()
inspect()

Inspects the network state.

set_defaults()
class dockermap.map.state.base.SingleStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.AbstractStateGenerator

get_states(config_ids)

Generates state information for the selected containers.

Parameters:config_ids (list[dockermap.map.input.MapConfigId]) – List of MapConfigId tuples.
Returns:Iterable of configuration states.
Return type:collections.Iterable[dockermap.map.state.ConfigState]
policy_options = [u'nonrecoverable_exit_codes', u'force_update']
class dockermap.map.state.base.VolumeBaseState(*args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Base implementation for determining the current state of a single volume on the client.

Parameters:
get_state()
inspect()

Inspects the network state.

set_defaults()
dockermap.map.state.base.format_image_tag()

S.format(*args, **kwargs) -> unicode

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{‘ and ‘}’).

dockermap.map.state.initial module

class dockermap.map.state.initial.InitialState(policy, options, client_name, config_id, config_flags=ConfigFlags(), *args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Assumes every item to be absent. This is intended for testing and situations where the actual state cannot be determined.

get_state()
inspect()
class dockermap.map.state.initial.InitialStateGenerator(policy, kwargs)

Bases: dockermap.map.state.base.DependencyStateGenerator

container_state_class

alias of InitialState

image_state_class

alias of PresentState

network_state_class

alias of InitialState

policy_options = [u'nonrecoverable_exit_codes', u'force_update']
volume_state_class

alias of InitialState

class dockermap.map.state.initial.PresentState(policy, options, client_name, config_id, config_flags=ConfigFlags(), *args, **kwargs)

Bases: dockermap.map.state.base.AbstractState

Assumes every item to be present. This is intended for testing and situations where the actual state cannot be determined.

get_state()
inspect()

dockermap.map.state.utils module

dockermap.map.state.utils.merge_dependency_paths(item_paths)

Utility function that merges multiple dependency paths, as far as they share dependencies. Paths are evaluated and merged in the incoming order. Later paths that are independent, but share some dependencies, are shortened by these dependencies. Paths that are contained in another entirely are discarded.

Parameters:item_paths (collections.Iterable[(Any, list[Any])]) – List or tuple of items along with their dependency path.
Returns:List of merged or independent paths.
Return type:list[(Any, list[Any])]

Module contents

class dockermap.map.state.ConfigState(client_name, config_id, config_flags, base_state, state_flags, extra_data)

Bases: tuple

base_state

Alias for field number 3

client_name

Alias for field number 0

config_flags

Alias for field number 2

config_id

Alias for field number 1

extra_data

Alias for field number 5

state_flags

Alias for field number 4

class dockermap.map.state.State

Bases: dockermap.map.SimpleEnum

ABSENT = u'absent'
PRESENT = u'present'
RUNNING = u'running'
class dockermap.map.state.StateFlags

Bases: dockermap.map.Flags

EXEC_COMMANDS = StateFlags(EXEC_COMMANDS)
FORCED_RESET = StateFlags(NEEDS_RESET, FORCED_RESET)
HOST_CONFIG_UPDATE = StateFlags(HOST_CONFIG_UPDATE)
IMAGE_MISMATCH = StateFlags(IMAGE_MISMATCH, NEEDS_RESET)
INITIAL = StateFlags(INITIAL)
MISC_MISMATCH = StateFlags(NEEDS_RESET, MISC_MISMATCH)
NEEDS_RESET = StateFlags(IMAGE_MISMATCH, NEEDS_RESET, MISC_MISMATCH, MISSING_LINK, FORCED_RESET, VOLUME_MISMATCH, NONRECOVERABLE)
NETWORK_DISCONNECTED = StateFlags(NETWORK_DISCONNECTED)
NETWORK_LEFT = StateFlags(NETWORK_LEFT)
NETWORK_MISMATCH = StateFlags(NETWORK_MISMATCH)
NONE = StateFlags()
NONRECOVERABLE = StateFlags(NEEDS_RESET, NONRECOVERABLE)
PERSISTENT = StateFlags(PERSISTENT)
RESTARTING = StateFlags(RESTARTING)
VOLUME_MISMATCH = StateFlags(NEEDS_RESET, VOLUME_MISMATCH)
fields = {'IMAGE_MISMATCH': 4096, 'NEEDS_RESET': 3221255168, 'NONE': 0, 'NETWORK_MISMATCH': 4194304, 'MISC_MISMATCH': 1073741824, 'MISSING_LINK': 8192, 'INITIAL': 1, 'FORCED_RESET': 2147483648, 'PERSISTENT': 32, 'VOLUME_MISMATCH': 16384, 'EXEC_COMMANDS': 32768, 'NONRECOVERABLE': 1024, 'RESTARTING': 2, 'NETWORK_LEFT': 2097152, 'NETWORK_DISCONNECTED': 1048576, 'HOST_CONFIG_UPDATE': 65536}