Inmanta API reference — Inmanta 2017.4dev documentation

# Inmanta API reference

## Plugins

class `inmanta.plugins.` `Context`(resolver, queue, owner, result)

  An instance of this class is used to pass context to the plugin

  `emit_expression`(stmt)

    Add a new statement

  `get_client`()
  `get_compiler`()
  `get_data_dir`()

    Get the path to the data dir (and create if it does not exist yet

  `get_queue_scheduler`()
  `get_resolver`()
  `get_type`(name: str)

    Get a type from the configuration model.

  `run_sync`(function: typing.Callable, timeout: int = 5)

    Execute the async function and return its result. This method takes care of starting and stopping the ioloop. The main use for this function is to use the inmanta internal rpc to communicate with the server.

    Parameters: | function (`Callable`) – The async function to execute. This function should return a yieldable object. timeout (`int`) – A timeout for the async function.
    Returns: | The result of the async call.
    Raises: | ConnectionRefusedError – When the function timeouts this exception is raised.

`inmanta.plugins.` `plugin`(function: typing.Callable = None, commands: typing.List[str] = None, emits_statements: bool = False)

  Python decorator to register functions with inmanta as plugin

  Parameters: | function (`Callable`) – The function to register with inmanta. This is the first argument when it is used as decorator. commands (`List`) – A list of command paths that need to be available. Inmanta raises an exception when the command is not available. emits_statements (`bool`) – Set to true if this plugin emits new statements that the compiler should execute. This is only required for complex plugins such as integrating a template engine.

## Resources

`inmanta.resources.` `resource`(name: str, id_attribute: str, agent: str)

  A decorator that registers a new resource. The decorator must be applied to classes that inherit from `Resource`

  Parameters: | name (`str`) – The name of the entity in the configuration model it creates a resources from. For example `std::File` id_attribute (`str`) – The attribute of this resource that uniquely identifies a resource on an agent. This attribute can be mapped. agent (`str`) – This string indicates how the agent of this resource is determined. This string points to an attribute, but it can navigate relations (this value cannot be mapped). For example, the agent argument could be `host.name`

class `inmanta.resources.` `Resource`(_id)

  Plugins should inherit resource from this class so a resource from a model can be serialized and deserialized.

  Such as class is registered when the `resource()` decorator is used. Each class needs to indicate the fields the resource will have with a class field named “fields”. A metaclass merges all fields lists from the class itself and all superclasses. If a field it not available directly in the model object the serializer will look for static methods in the class with the name “get_$fieldname”.

  `clone`(**kwargs) → inmanta.resources.Resource

    Create a clone of this resource. The given kwargs can be used to override attributes.

    Returns: | The cloned resource

class `inmanta.resources.` `PurgeableResource`(_id)

  See `std::PurgeableResource` for more information.

class `inmanta.resources.` `ManagedResource`(_id)

  See `std::ManagedResource` for more information.

class `inmanta.resources.` `IgnoreResourceException`

  Throw this exception when a resource should not be included by the exported.

## Handlers

`inmanta.agent.handler.` `cache`(f=None, ignore: typing.List[str] = [], timeout: int = 5000, for_version: bool = True, cache_none: bool = True, cacheNone: bool = True)

  decorator for methods in resource handlers to provide caching

  this decorator works similar to memoization: when the decorate method is called, its return value is cached, for subsequent calls, the cached value is used instead of the actual value

  The name of the method + the arguments of the method form the cache key

  If an argument named version is present and for_version is True, the cache entry is flushed after this version has been deployed If an argument named resource is present, it is assumed to be a resource and its ID is used, without the version information

  Parameters: | timeout (`int`) – the number of second this cache entry should live for_version (`bool`) – if true, this value is evicted from the cache when this deploy is ready ignore (`List`) – a list of argument names that should not be part of the cache key cache_none (`bool`) – cache returned none values

`inmanta.agent.handler.` `provider`(resource_type: str, name: str)

  A decorator that registers a new handler.

  Parameters: | resource_type (`str`) – The type of the resource this handler provides an implementation for. For example, `std::File` name (`str`) – A name to reference this provider.

class `inmanta.agent.handler.` `SkipResource`

  Bases: `Exception`

  A handler should raise this exception when a resource should be skipped. The resource will be marked as skipped instead of failed.

class `inmanta.agent.handler.` `ResourcePurged`

  If the `read_resource()` method raises this exception, the agent will mark the current state of the resource as purged.

class `inmanta.agent.handler.` `HandlerContext`(resource, dry_run=False, action_id=None)

  Context passed to handler methods for state related “things”

  `add_change`(name: str, desired: typing.Any, current: typing.Any = None) → None

    Report a change of a field. This field is added to the set of updated fields

    Parameters: | name (`str`) – The name of the field that was updated desired – The desired value to which the field was updated (or should be updated) current – The value of the field before it was updated

  `add_changes`(**kwargs)

    Report a list of changes at once as kwargs

    Parameters: | key – The name of the field that was updated. This field is also added to the set of updated fields value – The desired value of the field.

    To report the previous value of the field, use the add_change method

  `critical`(msg: str, *args, **kwargs) → None

    Log ‘msg % args’ with severity ‘CRITICAL’.

    To pass exception information, use the keyword argument exc_info with a true value, e.g.

    `logger.critical("Houston, we have a %s", "major disaster", exc_info=1)`

  `debug`(msg: str, *args, **kwargs) → None

    Log ‘msg % args’ with severity ‘DEBUG’.

    To pass exception information, use the keyword argument exc_info with a true value, e.g.

    `logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)`

  `error`(msg: str, *args, **kwargs) → None

    Log ‘msg % args’ with severity ‘ERROR’.

    To pass exception information, use the keyword argument exc_info with a true value, e.g.

    `logger.error("Houston, we have a %s", "major problem", exc_info=1)`

  `exception`(msg: str, *args, exc_info=True, **kwargs) → None

    Convenience method for logging an ERROR with exception information.

  `fields_updated`(fields)

    Report that fields have been updated

  `info`(msg: str, *args, **kwargs) → None

    Log ‘msg % args’ with severity ‘INFO’.

    To pass exception information, use the keyword argument exc_info with a true value, e.g.

    `logger.info("Houston, we have a %s", "interesting problem", exc_info=1)`

  `is_dry_run`()

    Is this a dryrun?

  `set_status`(status: inmanta.const.ResourceState) → None

    Set the status of the handler operation.

  `update_changes`(changes: dict)

    Update the changes list with changes

    Parameters: | changes (`dict`) – This should be a dict with a value a dict containing “current” and “desired” keys

  `warning`(msg: str, *args, **kwargs) → None

    Log ‘msg % args’ with severity ‘WARNING’.

    To pass exception information, use the keyword argument exc_info with a true value, e.g.

    `logger.warning("Houston, we have a %s", "bit of a problem", exc_info=1)`

class `inmanta.agent.handler.` `ResourceHandler`(agent, io=None) → None

  A baseclass for classes that handle resources. New handler are registered with the `provider()` decorator.

  The implementation of a handler should use the `self._io` instance to execute io operations. This io objects makes abstraction of local or remote operations. See `LocalIO` for the available operations.

  Parameters: | agent – The agent that is executing this handler. io – The io object to use.

  `_diff`(current: inmanta.resources.Resource, desired: inmanta.resources.Resource) → typing.Dict[str, typing.Dict[str, typing.Any]]

    Calculate the diff between the current and desired resource state.

    Return type: | `Dict`
    Parameters: | current (`Resource`) – The current state of the resource desired (`Resource`) – The desired state of the resource
    Returns: | A dict with key the name of the field and value another dict with “current” and “desired” as keys for fields that require changes.

  `available`(resource: inmanta.resources.Resource) → bool

    Returns true if this handler is available for the given resource

    Return type: | `bool`
    Parameters: | resource (`Resource`) – Is this handler available for the given resource?
    Returns: | Available or not?

  `can_process_events`() → bool

    Can this handler process events? This is a more generic version of the reload mechanism.

    See the `ResourceHandler.process_events()` for more details about this mechanism.

    Returns: | Return true if this handler processes events.

  `can_reload`() → bool

    Can this handler reload?

    Returns: | Return true if this handler needs to reload on requires changes.

  `check_facts`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → dict

    This method is called by the agent to query for facts. It runs `pre()` and `post()`. This method calls `facts()` to do the actually querying.

    Return type: | `dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.
    Returns: | A dict with fact names as keys and facts values.

  `check_resource`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → inmanta.resources.Resource

    Check the current state of a resource

    Return type: | `Resource`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of.
    Returns: | A resource to represents the current state. Use the `clone()` to create clone of the given resource that can be modified.

  `close`() → None
  `do_changes`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource, changes: dict) → None

    Do the changes required to bring the resource on this system in the state of the given resource.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of. changes (`dict`) – The changes that need to occur as reported by `list_changes()`

  `do_reload`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Perform a reload of this resource.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to reload.

  `execute`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource, dry_run: bool = False) → None

    Update the given resource. This method is called by the agent. Most handlers will not override this method and will only override `check_resource()`, optionally `list_changes()` and `do_changes()`

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of. dry_run (`bool`) – True will only determine the required changes but will not execute them.

  `facts`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → dict

    Returns facts about this resource. Override this method to implement fact querying. `pre()` and `post()` are called before and after this method.

    Return type: | `dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.
    Returns: | A dict with fact names as keys and facts values.

  `get_client`() → inmanta.protocol.AgentClient

    Get the client instance that identifies itself with the agent session.

    Returns: | A client that is associated with the session of the agent that executes this handler.

  `get_file`(hash_id) → bytes

    Retrieve a file from the fileserver identified with the given id. The convention is to use the sha1sum of the content to identify it.

    Return type: | `bytes`
    Parameters: | hash_id – The id of the content/file to retrieve from the server.
    Returns: | The content in the form of a bytestring or none is the content does not exist.

  `list_changes`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → typing.Dict[str, typing.Dict[str, typing.Any]]

    Returns the changes required to bring the resource on this system in the state described in the resource entry. This method calls `check_resource()`

    Return type: | `Dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of.
    Returns: | A dict with key the name of the field and value another dict with “current” and “desired” as keys for fields that require changes.

  `post`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Method executed after an operation. Override this method to run after an operation.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.

  `pre`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Method executed before a handler operation (Facts, dryrun, real deployment, …) is executed. Override this method to run before an operation.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.

  `process_events`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource, events: dict) → None

    Process events generated by changes to required resources. Override this method to process events in a handler. This method implements the deprecated reload mechanism. Make sure to call this method from a subclass if the reload behaviour is required.

    This method is called for all dependents of the given resource (inverse of the requires relationship) that have send_event set to true and for which a deploy was started. These are the only conditions, even if all dependents have failed or no changes were deployed. It is up to the handler to decide what to do.

    The default implementation provides the reload mechanism. It will call do_reload when the handler can_reload() and if at least one of the dependents have successfully deployed and there were changes.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to process the events for. dict – A dict with events of the resource the given resource requires. The keys of the dict are the resources. Each value is a dict with the items status (const.ResourceState), changes (dict) and change (const.Change).

  `restore`(resource: inmanta.resources.Resource, snapshot_id: str) → None

    Restore a resource from a snapshot.

    Parameters: | resource (`Resource`) – The resource for which a snapshot needs to be restored. snapshot_id (`str`) – The id of the “file” on the server that contains the snapshot data. This data can be retrieved with the `get_file()` method

  `run_sync`(func: typing.Callable) → typing.Any

    Run a the given async function on the ioloop of the agent. It will block the current thread until the future resolves.

    Parameters: | func (`Callable`) – A function that returns a yieldable future.
    Returns: | The result of the async function.

  `set_cache`(cache: inmanta.agent.cache.AgentCache) → None
  `snapshot`(resource: inmanta.resources.Resource) → bytes

    Create a new snapshot and upload it to the server

    Return type: | `bytes`
    Parameters: | resource (`Resource`) – The state of the resource for which a snapshot is created
    Returns: | The data that needs to be uploaded to the server. This data is passed back to the restore method on snapshot restore.

  `stat_file`(hash_id: str) → bool

    Check if a file exists on the server. This method does and async call to the server and blocks on the result.

    Return type: | `bool`
    Parameters: | hash_id (`str`) – The id of the file on the server. The convention is the use the sha1sum of the content as id.
    Returns: | True if the file is available on the server.

  `upload_file`(hash_id: str, content: bytes) → None

    Upload a file to the server

    Parameters: | hash_id (`str`) – The id to identify the content. The convention is to use the sha1sum of the content to identify it. content (`bytes`) – A byte string with the content

class `inmanta.agent.handler.` `CRUDHandler`(agent, io=None) → None

  This handler base class requires CRUD methods to be implemented: create, read, update and delete. Such a handler only works on purgeable resources.

  `available`(resource: inmanta.resources.Resource) → bool

    Returns true if this handler is available for the given resource

    Return type: | `bool`
    Parameters: | resource (`Resource`) – Is this handler available for the given resource?
    Returns: | Available or not?

  `can_process_events`() → bool

    Can this handler process events? This is a more generic version of the reload mechanism.

    See the `ResourceHandler.process_events()` for more details about this mechanism.

    Returns: | Return true if this handler processes events.

  `can_reload`() → bool

    Can this handler reload?

    Returns: | Return true if this handler needs to reload on requires changes.

  `check_facts`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → dict

    This method is called by the agent to query for facts. It runs `pre()` and `post()`. This method calls `facts()` to do the actually querying.

    Return type: | `dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.
    Returns: | A dict with fact names as keys and facts values.

  `check_resource`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → inmanta.resources.Resource

    Check the current state of a resource

    Return type: | `Resource`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of.
    Returns: | A resource to represents the current state. Use the `clone()` to create clone of the given resource that can be modified.

  `close`() → None
  `create_resource`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.PurgeableResource) → None

    This method is called by the handler when the resource should be created.

    Parameters: | context – Context can be used to get values discovered in the read method. For example, the id used in API calls. This context should also be used to let the handler know what changes were made to the resource. resource (`PurgeableResource`) – The desired resource state.

  `delete_resource`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.PurgeableResource) → None

    This method is called by the handler when the resource should be deleted.

    Parameters: | ctx (`HandlerContext`) – Context can be used to get values discovered in the read method. For example, the id used in API calls. This context should also be used to let the handler know what changes were made to the resource. resource (`PurgeableResource`) – The desired resource state.

  `do_changes`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource, changes: dict) → None

    Do the changes required to bring the resource on this system in the state of the given resource.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of. changes (`dict`) – The changes that need to occur as reported by `list_changes()`

  `do_reload`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Perform a reload of this resource.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to reload.

  `execute`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.PurgeableResource, dry_run: bool = None) → None

    Update the given resource. This method is called by the agent. Override the CRUD methods of this class.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`PurgeableResource`) – The resource to check the current state of. dry_run (`bool`) – True will only determine the required changes but will not execute them.

  `facts`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → dict

    Returns facts about this resource. Override this method to implement fact querying. `pre()` and `post()` are called before and after this method.

    Return type: | `dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.
    Returns: | A dict with fact names as keys and facts values.

  `get_client`() → inmanta.protocol.AgentClient

    Get the client instance that identifies itself with the agent session.

    Returns: | A client that is associated with the session of the agent that executes this handler.

  `get_file`(hash_id) → bytes

    Retrieve a file from the fileserver identified with the given id. The convention is to use the sha1sum of the content to identify it.

    Return type: | `bytes`
    Parameters: | hash_id – The id of the content/file to retrieve from the server.
    Returns: | The content in the form of a bytestring or none is the content does not exist.

  `list_changes`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → typing.Dict[str, typing.Dict[str, typing.Any]]

    Returns the changes required to bring the resource on this system in the state described in the resource entry. This method calls `check_resource()`

    Return type: | `Dict`
    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to check the current state of.
    Returns: | A dict with key the name of the field and value another dict with “current” and “desired” as keys for fields that require changes.

  `post`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Method executed after an operation. Override this method to run after an operation.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.

  `pre`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource) → None

    Method executed before a handler operation (Facts, dryrun, real deployment, …) is executed. Override this method to run before an operation.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to query facts for.

  `process_events`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.Resource, events: dict) → None

    Process events generated by changes to required resources. Override this method to process events in a handler. This method implements the deprecated reload mechanism. Make sure to call this method from a subclass if the reload behaviour is required.

    This method is called for all dependents of the given resource (inverse of the requires relationship) that have send_event set to true and for which a deploy was started. These are the only conditions, even if all dependents have failed or no changes were deployed. It is up to the handler to decide what to do.

    The default implementation provides the reload mechanism. It will call do_reload when the handler can_reload() and if at least one of the dependents have successfully deployed and there were changes.

    Parameters: | ctx (`HandlerContext`) – Context object to report changes and logs to the agent and server. resource (`Resource`) – The resource to process the events for. dict – A dict with events of the resource the given resource requires. The keys of the dict are the resources. Each value is a dict with the items status (const.ResourceState), changes (dict) and change (const.Change).

  `read_resource`(ctx: inmanta.agent.handler.HandlerContext, resource: inmanta.resources.PurgeableResource) → None

    This method reads the current state of the resource. It provides a copy of the resource that should be deployed, the method implementation should modify the attributes of this resource to the current state.

    Parameters: | ctx (`HandlerContext`) – Context can be used to pass value discovered in the read method to the CUD methods. For example, the id used in API calls resource (`PurgeableResource`) – A clone of the desired resource state. The read method need to set values on this object.
    Raises: | SkipResource – Raise this exception when the handler should skip this resource ResourcePurged – Raise this exception when the resource does not exist yet.

  `restore`(resource: inmanta.resources.Resource, snapshot_id: str) → None

    Restore a resource from a snapshot.

    Parameters: | resource (`Resource`) – The resource for which a snapshot needs to be restored. snapshot_id (`str`) – The id of the “file” on the server that contains the snapshot data. This data can be retrieved with the `get_file()` method

  `run_sync`(func: typing.Callable) → typing.Any

    Run a the given async function on the ioloop of the agent. It will block the current thread until the future resolves.

    Parameters: | func (`Callable`) – A function that returns a yieldable future.
    Returns: | The result of the async function.

  `set_cache`(cache: inmanta.agent.cache.AgentCache) → None
  `snapshot`(resource: inmanta.resources.Resource) → bytes

    Create a new snapshot and upload it to the server

    Return type: | `bytes`
    Parameters: | resource (`Resource`) – The state of the resource for which a snapshot is created
    Returns: | The data that needs to be uploaded to the server. This data is passed back to the restore method on snapshot restore.

  `stat_file`(hash_id: str) → bool

    Check if a file exists on the server. This method does and async call to the server and blocks on the result.

    Return type: | `bool`
    Parameters: | hash_id (`str`) – The id of the file on the server. The convention is the use the sha1sum of the content as id.
    Returns: | True if the file is available on the server.

  `update_resource`(ctx: inmanta.agent.handler.HandlerContext, changes: dict, resource: inmanta.resources.PurgeableResource) → None

    This method is called by the handler when the resource should be updated.

    Parameters: | ctx (`HandlerContext`) – Context can be used to get values discovered in the read method. For example, the id used in API calls. This context should also be used to let the handler know what changes were made to the resource. changes (`dict`) – A map of resource attributes that should be changed. Each value is a tuple with the current and the desired value. resource (`PurgeableResource`) – The desired resource state.

  `upload_file`(hash_id: str, content: bytes) → None

    Upload a file to the server

    Parameters: | hash_id (`str`) – The id to identify the content. The convention is to use the sha1sum of the content to identify it. content (`bytes`) – A byte string with the content

class `inmanta.agent.io.local.` `LocalIO`(uri, config)

  This class provides handler IO methods

  `chmod`(path, permissions)

    Change the permissions

    Parameters: | path (str) – The path of the file or directory to change the permission of. permissions (str) – An octal string with the permission to set.

  `chown`(path, user=None, group=None)

    Change the ownership of a file.

    Parameters: | path (str) – The path of the file or directory to change the ownership of. user (str) – The user to change to group (str) – The group to change to

  `close`()

    Close any resources

  `file_exists`(path)

    Check if a given file exists

    Parameters: | path (str) – The path to check if it exists.
    Returns: | Returns true if the file exists
    Return type: | bool

  `file_stat`(path)

    Do a stat call on a file

    Parameters: | path (str) – The file or direct to stat
    Returns: | A dict with the owner, group and permissions of the given path
    Return type: | dict[str, str]

  `hash_file`(path)

    Return the sha1sum of the file at path

    Parameters: | path (str) – The path of the file to hash the content of
    Returns: | The sha1sum in a hex string
    Return type: | str

  `is_remote`()

    Are operation executed remote

    Returns: | Returns true if the io operations are remote.
    Return type: | bool

  `is_symlink`(path)

    Is the given path a symlink

    Parameters: | path (str) – The path of the symlink
    Returns: | Returns true if the given path points to a symlink
    Return type: | str

  `mkdir`(path)

    Create a directory

    Parameters: | path (str) – Create this directory. The parent needs to exist.

  `put`(path, content)

    Put the given content at the given path

    Parameters: | path (str) – The location where to write the file content (bytes) – The binarystring content to write to the file.

  `read`(path)

    Read in the file in path and return its content as string

    Parameters: | path (str) – The path of the file to read.
    Returns: | The string content of the file
    Return type: | string

  `read_binary`(path)

    Read in the file in path and return its content as a bytestring

    Parameters: | path (str) – The path of the file to read.
    Returns: | The byte content of the file
    Return type: | bytes

  `readlink`(path)

    Return the target of the path

    Parameters: | path (str) – The symlink to get the target for.
    Returns: | The target of the symlink
    Return type: | str

  `remove`(path)

    Remove a file

    Parameters: | path (str) – The path of the file to remove.

  `rmdir`(path)

    Remove a directory

    Parameters: | path (str) – The directory to remove

  `run`(command, arguments=[], env=None, cwd=None, timeout=None)

    Execute a command with the given argument and return the result

    Parameters: | command (str) – The command to execute. arguments (list) – The arguments of the command env (dict) – A dictionary with environment variables. cwd (str) – The working dir to execute the command in. timeout (int) – The timeout for this command. This parameter is ignored if the command is executed remotely with a python 2 interpreter.
    Returns: | A tuple with (stdout, stderr, returncode)
    Return type: | tuple

  `symlink`(source, target)

    Symlink source to target

    Parameters: | source (str) – Create a symlink of this path to target target (str) – The path of the symlink to create