accasim.base.resource_manager_class module

MIT License

Copyright (c) 2017 cgalleguillosm

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

exception accasim.base.resource_manager_class.ResourceError[source]

Bases: Exception

class accasim.base.resource_manager_class.ResourceManager(_resource)[source]

Bases: object

allocate_event(event, node_names)[source]

Method for job allocation. It uses the event request to determine the resources to be allocated.

Parameters:
  • event – Job event object.
  • node_names – List of nodes where the job will be allocated.
Returns:

Tuple: First element True if the event was allocated, False otherwise. Second element a message.

current_allocations
current_availability

Return system availability

Type:return
current_usage
groups_available_resource(_key=None)[source]
Parameters:_key – None for values of all types for all groups. Giving a specific key will return the resource for the specific type
Todo:Use NODE_LIST instead items
Returns:Dictionary of {group{type: value}}
node_names

Return node names

Type:return
node_resources(*args)[source]
Parameters:*args – list of node names

Print nodes and its resources

remove_event(id)[source]

Method for job release. It release the allocated resources on the specific nodes.

Parameters:id – Job Id
resource_types

Return resource types of the system

Type:return
system_capacity(type)[source]
Parameters:type – ‘total’ to return the total per resource type ‘nodes’ to return the capacity of nodes
Returns:Return system capacity
system_resource_types()[source]
system_resources()[source]
total_resources(*args)[source]

Return the total system resource for the required argument. The resource has to exist in the system. If no arguments is proportioned all resources are returned. @todo: Use NODE_LIST instead items

Parameters:*args – Depends on the system configuration. But at least it must have (‘core’, ‘mem’) resources.
Returns:Dictionary of the resources and its values.
class accasim.base.resource_manager_class.Resources(groups, resources, **kwargs)[source]

Bases: object

resources class: Stablish the resources, allocate and release their use.

OFF = 0
ON = 1
allocate(node_name, **kwargs)[source]

Method for job allocation. It receives the node name and the resources to be used.

Parameters:
  • node_name – Name of the node to be updated.
  • **kwargs – Dictionary of the system resources and its values to be used.
availability()[source]

Returns the current system availablity. It just return nodes that are ON.

Returns:Return a dictionary with the system availability. In terms of {node: {resource: value}}
release(node_name, **kwargs)[source]

Method for allocation release. It receives the node name and the resources to be released.

Parameters:
  • node_name – Name of the node to be updated.
  • **kwargs – Dictionary of the system resources and its values to be released.
resource_manager()[source]

Instantiation of the resource manager object

Returns:Resource manager object.
system_capacity(type='total')[source]
Parameters:type – ‘total’ to return the total per resource type ‘nodes’ to return the capacity of nodes
Returns:Return system capacity
system_groups()[source]

Returns the available system groups.

usage(type=None)[source]

System usage calculation @todo: Use NODE_LIST instead items

Returns:Return a string of the system usage