Class: Distem::Node::Admin
- Inherits:
-
Object
- Object
- Distem::Node::Admin
- Defined in:
- lib/distem/node/admin.rb
Overview
Class that allow to set up a physical node resources (init cgroups, tc, …)
Constant Summary
- PATH_DISTEM_LOGS =
The directory used to store distem logs
'/var/log/distem/'
- PATH_DISTEMTMP =
The directory used to store temporary files
'/tmp/distem/'
- PATH_SYSV_CGROUP =
The cgroups directory to use
'/dev/cgroup'
- MAX_VIFACES =
The default maximum number of virual network interfaces (used with ifb)
64
- MAX_PTY =
The default maximum number of PTY creatable on the physical machine
8192
- @@vifaces_max =
The maximal number of virtual network interfaces that can be created on this machine
MAX_VIFACES
Class Method Summary (collapse)
- + (Boolean) has_systemd?
-
+ (Object) init_node(pnode, properties)
Initialize a physical node (set cgroups, bridge, ifb, fill the PNode cpu and memory informations, …) ==== Attributes *
pnode
The PNode object that will be filled with different informations *properties
An hash containing specific initialization parameters (max_vifaces,). -
+ (Object) quit_node
Clean and unset all content set by the system (remove cgroups, bridge, ifb, temporary files, …).
-
+ (Object) set_cgroups
Initialize (mount) the CGroup filesystem that will be used by the system (LXC, …).
- + (Object) set_pty(num = MAX_PTY)
-
+ (Object) unset_cgroups
Clean (umount) the CGroup filesystem used by the system.
-
+ (Object) vifaces_max
Get the maximal number of vnodes that can be create on this machine ==== Returns Fixnum.
Class Method Details
+ (Boolean) has_systemd?
53 54 55 |
# File 'lib/distem/node/admin.rb', line 53 def self.has_systemd? return !File.exist?('/sbin/init') || ((File.ftype('/sbin/init') == 'link') && File.readlink('/sbin/init').include?('systemd')) end |
+ (Object) init_node(pnode, properties)
Initialize a physical node (set cgroups, bridge, ifb, fill the PNode cpu and memory informations, …)
Attributes
-
pnode
The PNode object that will be filled with different informations -
properties
An hash containing specific initialization parameters (max_vifaces,)
27 28 29 30 31 32 33 34 35 |
# File 'lib/distem/node/admin.rb', line 27 def self.init_node(pnode,properties) @@vifaces_max = properties['max_vifaces'].to_i if properties['max_vifaces'] set_cgroups() set_pty() Lib::NetTools.set_resource(@@vifaces_max,properties['set_bridge']) Lib::CPUTools.set_resource(pnode.cpu) Lib::MemoryTools.set_resource(pnode.memory) Lib::FileSystemTools.set_resource() end |
+ (Object) quit_node
Clean and unset all content set by the system (remove cgroups, bridge, ifb, temporary files, …)
47 48 49 50 51 |
# File 'lib/distem/node/admin.rb', line 47 def self.quit_node() Lib::NetTools.unset_ifb() unset_cgroups() Lib::Shell.run("rm -R #{PATH_DISTEMTMP}") if File.exist?(PATH_DISTEMTMP) end |
+ (Object) set_cgroups
Initialize (mount) the CGroup filesystem that will be used by the system (LXC, …)
58 59 60 61 62 63 |
# File 'lib/distem/node/admin.rb', line 58 def self.set_cgroups if !has_systemd? Lib::Shell.run("mkdir #{PATH_SYSV_CGROUP}") Lib::Shell.run("mount -t cgroup cgroup #{PATH_SYSV_CGROUP}") end end |
+ (Object) set_pty(num = MAX_PTY)
73 74 75 |
# File 'lib/distem/node/admin.rb', line 73 def self.set_pty(num=MAX_PTY) Lib::Shell.run("sysctl -w kernel.pty.max=#{num}") end |
+ (Object) unset_cgroups
Clean (umount) the CGroup filesystem used by the system
66 67 68 69 70 71 |
# File 'lib/distem/node/admin.rb', line 66 def self.unset_cgroups if !has_systemd? Lib::Shell.run("umount #{PATH_SYSV_CGROUP}") Lib::Shell.run("rmdir #{PATH_SYSV_CGROUP}") end end |
+ (Object) vifaces_max
Get the maximal number of vnodes that can be create on this machine
Returns
Fixnum
42 43 44 |
# File 'lib/distem/node/admin.rb', line 42 def self.vifaces_max() return @@vifaces_max end |