Class: Distem::Node::ConfigManager
- Inherits:
-
Object
- Object
- Distem::Node::ConfigManager
- Defined in:
- lib/distem/node/configmanager.rb
Overview
Class that help to set up a physical node resource specifying virtual ones
Instance Attribute Summary (collapse)
-
- (Object) pnode
The physical node to work on.
-
- (Object) vplatform
readonly
The virtual platform that describes all virtual resources set on this physical node.
Instance Method Summary (collapse)
-
- (Object) destroy(resource)
Remove a virtual resource (use it's _remove associated method) ==== Attributes *
resouce
The Resource object (have to be of class VNode, VNetwork or VRoute). -
- (Object) get_container(name)
Gets the Container object associated to a virtual node ==== Attributes *
name
The name of the virtual node (String) ==== Returns Container object or nil if not found. -
- (Object) get_vnode(name)
Gets a virtual node object specifying it's name ==== Attributes *
name
The name (String) ==== Returns VNode object or nil if not found. -
- (ConfigManager) initialize
constructor
Create a new ConfigManager object.
- - (Object) set_global_arptable(vnode, data, file)
- - (Object) set_global_etchosts(vnode, data)
-
- (Object) vnetwork_add(vnetwork)
Add a virtual network ==== Attributes *
vnetwork
The VNetwork object. -
- (Object) vnetwork_remove(vnetwork)
Remove a virtual network ==== Attributes *
vnetwork
The VNetwork object. -
- (Object) vnode_add(vnode)
Add a virtual node and initialize all the resources it will use on the physical node (uncompress it's filesystem, create it's container (cgroups,lxc, …), …) ==== Attributes *
vnode
The VNode object. - - (Object) vnode_freeze(vnode)
-
- (Object) vnode_reconfigure(vnode)
Reconfigure a virtual node (apply changes to the abstract virtual resources to the physical node settings) ==== Attributes *
vnode
The VNode object. -
- (Object) vnode_remove(vnode)
Remove a virtual node and clean all it's associated resources on the physical node (remove it's filesystem files, remove it's container (cgroups,lxc, …), …) ==== Attributes *
vnode
The VNode object. -
- (Object) vnode_start(vnode, distempnode)
Start a virtual node to be able to use it (it have to be installed and in the status READY) ==== Attributes *
vnode
The VNode object *distempnode
DistemPnode object. -
- (Object) vnode_stop(vnode)
Stop a virtual node (it have to be started and in the status RUNNING) ==== Attributes *
vnode
The VNode object. - - (Object) vnode_unfreeze(vnode)
-
- (Object) vnode_update(vnode)
Update a virtual node (apply/undo changes to the abstract virtual resources to the physical node settings) ==== Attributes *
vnode
The VNode object. -
- (Object) vroute_remove(vroute)
Remove a virtual route ==== Attributes *
vroute
The VRoute object.
Constructor Details
- (ConfigManager) initialize
Create a new ConfigManager object
14 15 16 17 18 19 |
# File 'lib/distem/node/configmanager.rb', line 14 def initialize @pnode = Distem::Resource::PNode.new(Lib::NetTools.get_default_addr()) @vplatform = Distem::Resource::VPlatform.new @containers = {} Container.clean() end |
Instance Attribute Details
- (Object) pnode
The physical node to work on
11 12 13 |
# File 'lib/distem/node/configmanager.rb', line 11 def pnode @pnode end |
- (Object) vplatform (readonly)
The virtual platform that describes all virtual resources set on this physical node
9 10 11 |
# File 'lib/distem/node/configmanager.rb', line 9 def vplatform @vplatform end |
Instance Method Details
- (Object) destroy(resource)
Remove a virtual resource (use it's _remove associated method)
Attributes
-
resouce
The Resource object (have to be of class VNode, VNetwork or VRoute)
173 174 175 176 177 178 179 180 181 |
# File 'lib/distem/node/configmanager.rb', line 173 def destroy(resource) if resource.is_a?(Resource::VNode) vnode_remove(resource) elsif resource.is_a?(Resource::VNetwork) vnetwork_remove(resource) elsif resource.is_a?(Resource::VRoute) vroute_remove(resource) end end |
- (Object) get_container(name)
Gets the Container object associated to a virtual node
Attributes
-
name
The name of the virtual node (String)
Returns
Container object or nil if not found
37 38 39 |
# File 'lib/distem/node/configmanager.rb', line 37 def get_container(name) return (@containers.has_key?(name) ? @containers[name] : nil) end |
- (Object) get_vnode(name)
Gets a virtual node object specifying it's name
Attributes
-
name
The name (String)
Returns
VNode object or nil if not found
27 28 29 |
# File 'lib/distem/node/configmanager.rb', line 27 def get_vnode(name) return @vplatform.get_vnode(name) end |
- (Object) set_global_arptable(vnode, data, file)
187 188 189 |
# File 'lib/distem/node/configmanager.rb', line 187 def set_global_arptable(vnode, data, file) @containers[vnode.name].set_global_arptable(data, file) end |
- (Object) set_global_etchosts(vnode, data)
183 184 185 |
# File 'lib/distem/node/configmanager.rb', line 183 def set_global_etchosts(vnode, data) @containers[vnode.name].set_global_etchosts(data) end |
- (Object) vnetwork_add(vnetwork)
Add a virtual network
Attributes
-
vnetwork
The VNetwork object
145 146 147 |
# File 'lib/distem/node/configmanager.rb', line 145 def vnetwork_add(vnetwork) @vplatform.add_vnetwork(vnetwork) end |
- (Object) vnetwork_remove(vnetwork)
Remove a virtual network
Attributes
-
vnetwork
The VNetwork object
153 154 155 156 157 158 159 |
# File 'lib/distem/node/configmanager.rb', line 153 def vnetwork_remove(vnetwork) #vnodes = vnetwork.vnodes.clone @vplatform.remove_vnetwork(vnetwork) #vnodes.each_pair do |vnode,viface| # vnode_configure(vnode) #end end |
- (Object) vnode_add(vnode)
Add a virtual node and initialize all the resources it will use on the physical node (uncompress it's filesystem, create it's container (cgroups,lxc, …), …)
Attributes
-
vnode
The VNode object
45 46 47 48 |
# File 'lib/distem/node/configmanager.rb', line 45 def vnode_add(vnode) # >>> TODO: Add the ability to modify a VNode @vplatform.add_vnode(vnode) end |
- (Object) vnode_freeze(vnode)
121 122 123 124 125 |
# File 'lib/distem/node/configmanager.rb', line 121 def vnode_freeze(vnode) if @containers[vnode.name] @containers[vnode.name].freeze end end |
- (Object) vnode_reconfigure(vnode)
Reconfigure a virtual node (apply changes to the abstract virtual resources to the physical node settings)
Attributes
-
vnode
The VNode object
95 96 97 98 99 |
# File 'lib/distem/node/configmanager.rb', line 95 def vnode_reconfigure(vnode) raise Lib::ResourceNotFoundError, vnode unless vnode @containers[vnode.name].reconfigure() end |
- (Object) vnode_remove(vnode)
Remove a virtual node and clean all it's associated resources on the physical node (remove it's filesystem files, remove it's container (cgroups,lxc, …), …)
Attributes
-
vnode
The VNode object
54 55 56 57 58 59 60 61 |
# File 'lib/distem/node/configmanager.rb', line 54 def vnode_remove(vnode) raise unless vnode.is_a?(Resource::VNode) if @containers[vnode.name] @containers[vnode.name].destroy @containers.delete(vnode.name) end @vplatform.remove_vnode(vnode) end |
- (Object) vnode_start(vnode, distempnode)
Start a virtual node to be able to use it (it have to be installed and in the status READY)
Attributes
-
vnode
The VNode object -
distempnode
DistemPnode object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/distem/node/configmanager.rb', line 74 def vnode_start(vnode, distempnode) if @containers[vnode.name] @containers[vnode.name].start() else @containers[vnode.name] = Node::Container.new(vnode) @containers[vnode.name].configure(distempnode) @containers[vnode.name].start() =begin vnode.vifaces.each do |viface| if viface.vtraffic? and !viface.limited? viface_configure(viface) end end =end end end |
- (Object) vnode_stop(vnode)
Stop a virtual node (it have to be started and in the status RUNNING)
Attributes
-
vnode
The VNode object
115 116 117 118 119 |
# File 'lib/distem/node/configmanager.rb', line 115 def vnode_stop(vnode) if @containers[vnode.name] @containers[vnode.name].stop() end end |
- (Object) vnode_unfreeze(vnode)
127 128 129 130 131 |
# File 'lib/distem/node/configmanager.rb', line 127 def vnode_unfreeze(vnode) if @containers[vnode.name] @containers[vnode.name].unfreeze end end |
- (Object) vnode_update(vnode)
Update a virtual node (apply/undo changes to the abstract virtual resources to the physical node settings)
Attributes
-
vnode
The VNode object
105 106 107 108 109 |
# File 'lib/distem/node/configmanager.rb', line 105 def vnode_update(vnode) raise Lib::ResourceNotFoundError, vnode unless vnode @containers[vnode.name].update() end |
- (Object) vroute_remove(vroute)
Remove a virtual route
Attributes
-
vroute
The VRoute object
165 166 167 |
# File 'lib/distem/node/configmanager.rb', line 165 def vroute_remove(vroute) @vplatform.remove_vroute(vroute) end |