# API Reference

`os_faults.``connect`(cloud_config=None, config_filename=None)

  Connects to the cloud

  Parameters:

  - cloud_config – dict with cloud and power management params
  - config_filename – name of the file where to read config from

  Returns: | CloudManagement object

`os_faults.``discover`(cloud_config)

  Connect to the cloud and discover nodes and services

  Parameters: | cloud_config – dict with cloud and power management params
  Returns: | config dict with discovered nodes/services

`os_faults.``human_api`(cloud_management, command)

  Executes a command written as English sentence

  Parameters:

  - cloud_management – library instance as returned by :connect: function
  - command – text command

`os_faults.``register_ansible_modules`(paths)

  Registers ansible modules by provided paths

  Allows to use custom ansible modules in NodeCollection.run_task method

  Parameters: | paths – list of paths to folders with ansible modules

class `os_faults.api.cloud_management.``CloudManagement`
  `execute_on_cloud`(hosts, task, raise_on_error=True)

    Execute task on specified hosts within the cloud.

    Parameters:

    - hosts – List of host FQDNs
    - task – Ansible task
    - raise_on_error – throw exception in case of error

    Returns: | Ansible execution result (list of records)

  `get_container`(name)

    Get container with specified name

    Parameters: | name – name of the container
    Returns: | Container

  `get_nodes`(fqdns=None)

    Get nodes in the cloud

    This function returns NodesCollection representing all nodes in the cloud or only those that has specified FQDNs. :param fqdns list of FQDNs or None to retrieve all nodes :return: NodesCollection

  `get_service`(name)

    Get service with specified name

    Parameters: | name – name of the service
    Returns: | Service

  classmethod `list_supported_networks`()

    Lists all networks supported by nodes returned by this driver

    Returns: | [String] list of network names

  classmethod `list_supported_services`()

    Lists all services supported by this driver

    Returns: | [String] list of service names

  `verify`()

    Verify connection to the cloud.

class `os_faults.api.service.``Service`(service_name, config, node_cls, cloud_management, hosts=None)
  `discover_nodes`()

    Discover nodes where this Service is running

    Returns: | NodesCollection

  `freeze`(nodes=None, sec=None)

    Pause service execution

    Send SIGSTOP to Service into network on all nodes or on particular subset. If sec is defined - it mean Service will be stopped for a wile.

    Parameters:

    - nodes – NodesCollection
    - sec – int

  `get_nodes`()

    Get nodes where this Service is running

    Returns: | NodesCollection

  `kill`(nodes=None)

    Terminate Service abruptly on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `plug`(nodes=None)

    Plug Service into network on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `restart`(nodes=None)

    Restart Service on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `start`(nodes=None)

    Start Service on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `terminate`(nodes=None)

    Terminate Service gracefully on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `unfreeze`(nodes=None)

    Resume service execution

    Send SIGCONT to Service into network on all nodes or on particular subset.

    Parameters: | nodes – NodesCollection

  `unplug`(nodes=None)

    Unplug Service out of network on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

class `os_faults.api.container.``Container`(container_name, config, node_cls, cloud_management, hosts=None)
  `discover_nodes`()

    Discover nodes where this Container is running

    Returns: | NodesCollection

  `get_nodes`()

    Get nodes where this Container is running

    Returns: | NodesCollection

  `restart`(nodes=None)

    Restart Container on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `start`(nodes=None)

    Start Container on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

  `terminate`(nodes=None)

    Terminate Container gracefully on all nodes or on particular subset

    Parameters: | nodes – NodesCollection

class `os_faults.api.node_collection.``NodeCollection`(cloud_management=None, hosts=None)
  `connect`(network_name)

    Connect nodes to <network_name> network

    Parameters: | network_name – name of network

  `disconnect`(network_name)

    Disconnect nodes from <network_name> network

    Parameters: | network_name – name of network

  `oom`()

    Fill all node’s RAM

  `pick`(count=1)

    Pick one Node out of collection

    Returns: | NodeCollection consisting just one node

  `poweroff`()

    Power off all nodes abruptly

  `poweron`()

    Power on all nodes abruptly

  `reboot`()

    Reboot all nodes gracefully

  `reset`()

    Reset (cold restart) all nodes

  `revert`(snapshot_name, resume=True)

    Revert snapshot for all nodes

  `run_task`(task, raise_on_error=True)

    Run ansible task on node colection

    Parameters:

    - task – ansible task as dict
    - raise_on_error – throw exception in case of error

    Returns: | AnsibleExecutionRecord with results of task

  `shutdown`()

    Shutdown all nodes gracefully

  `snapshot`(snapshot_name, suspend=True)

    Create snapshot for all nodes

  `stress`(target, duration=None)

    Stress node OS and hardware