This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
[![Build Status](https://travis-ci.org/cloudsigma/cgroupspy.svg)](https://travis-ci.org/cloudsigma/cgroupspy)
cgroupspy
=========

Python library for managing cgroups

The library provides a pythonic way to manage and represent cgroups. It provides interfaces that convert
python objects to cgroups compatible strings and vise versa.


Trees
-----
cgroupspy has a couple of ways to represent the cgroups filesystem

* As a tree - this is the most basic and generic way to represent them. You basically construct it from all
the directories in the cgroups root.

* A grouped tree - that has access to all cgroup partitions with the same name, on the same level. For example -
'machine' partition in memory, cpuset, cpus, etc cgroups. All these attributes are
accessed via machine.cpus, machine.cpuset, etc.

* A VMTree - a subclass of grouped tree with utilities for simple management of libvirt guests

Example usage
-------------
```python
#Import the trees module, which contains a tree representation of cgroups
>>> from cgroupspy import trees

# This is the most basic type of cgroup tree. It models the filesystem.
>>> t = trees.Tree()

# It has a root which is of type Node
>>> t.root
<node/>

# And the root has children
>>> print(t.root.children)
[<node hugetlb="">, <node net_prio="">, <node perf_event="">, <node blkio="">, <node net_cls="">, <node freezer="">, <node devices="">, <node memory="">, <node cpuacct="">, <node cpu="">, <node cpuset="">, <node systemd="">, <node cgmanager="">]

# You can for example get the cpuset
>>> cset = t.get_node_by_path('/cpuset/')
>>> cset
<node cpuset="">

# The controller used for this cgroup is a CpuSetController
>>> cset.controller
<cgroupspy.controllers.cpusetcontroller object="" at="" 0x7f63a3843050="">

# Which can for example show you the cpu pinning
>>> cset.controller.cpus
set([0, 1])

# You can create a cgroup
>>> test = cset.create_cgroup('test')
<node cpuset="" test="">

# See its cpu restrictions
>>> test.controller.cpus
set([0, 1])

# And change them
>>> test.controller.cpus = [1]

# The tasks in this cgroup are now restricted to cpu 1
>>> test.controller.cpus
set([1])
```

Another example with the VMTree - for managing libvirt guests

```python
>>> from cgroupspy.trees import VMTree
>>> vmt = VMTree()
>>> print(vmt.vms)
{u'1ce10f47-fb4e-4b6a-8ee6-ba34940cdda7.libvirt-qemu': <nodevm 1ce10f47-fb4e-4b6a-8ee6-ba34940cdda7.libvirt-qemu="">,
u'3d5013b9-93ed-4ef1-b518-a2cea43f69ad.libvirt-qemu': <nodevm 3d5013b9-93ed-4ef1-b518-a2cea43f69ad.libvirt-qemu="">,
}

>>> vm = vmt.get_vm_node("1ce10f47-fb4e-4b6a-8ee6-ba34940cdda7")
>>> print(vm.cpu.shares)
1024
>>> print(vm.cpuset.cpus)
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
>>> print(vm.memory.limit_in_bytes)
25603080192
>>> print(vm.children)
[<nodecontrolgroup vcpu1="">,
<nodecontrolgroup vcpu0="">,
<nodecontrolgroup emulator="">]
>>> print(vm.path)
/machine/grey/1ce10f47-fb4e-4b6a-8ee6-ba34940cdda7.libvirt-qemu
>>> vcpu1 = vm.children[0]
>>> print(vcpu1.cpuset.cpus)
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

>>> vcpu1.cpuset.cpus = {1,2,3}

>>> print(vcpu1.cpuset.cpus)
{1, 2, 3}
```

License
-------
new BSD licence
Release History

Release History

0.1.5

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cgroupspy-0.1.5.tar.gz (11.0 kB) Copy SHA256 Checksum SHA256 Source Sep 1, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting