Class: Distem::Resource::PNode
- Inherits:
-
Object
- Object
- Distem::Resource::PNode
- Defined in:
- lib/distem/resource/pnode.rb
Overview
Abstract representation of a physical machine/node (the machine that will be used to launch some virtual nodes)
Constant Summary
- @@ids =
0
Instance Attribute Summary (collapse)
-
- (Object) address
readonly
The IP address of the machine.
-
- (Object) algorithms
The emulation algorithms that are used on this physical node (Hash).
-
- (Object) cpu
The machine's CPU description.
-
- (Object) id
readonly
The unique id of the machine.
-
- (Object) local_vifaces
The number of local vifaces.
-
- (Object) memory
The machine's memory description.
-
- (Object) ssh_password
readonly
Deprecated, used to contact the physical node if the SSH key file is not set.
-
- (Object) ssh_user
readonly
Deprecated, used to contact the physical node if the SSH key file is not set.
-
- (Object) status
The status in which the Node is (see Status).
Instance Method Summary (collapse)
-
- (Object) ==(pnode)
Compare two PNodes (based on the host address) ==== Returns Boolean value.
-
- (PNode) initialize(hostname, ssh_user = "root", ssh_password = "")
constructor
Create a new PNode ==== Attributes *
hostname
The hostname/address of the physical machine ==== Examples pnode = PNode.new(“10.16.0.1”) OR pnode = PNode.new(“my-node.lan”).
Constructor Details
- (PNode) initialize(hostname, ssh_user = "root", ssh_password = "")
Create a new PNode
Attributes
-
hostname
The hostname/address of the physical machine
Examples
pnode = PNode.new("10.16.0.1")
OR
pnode = PNode.new("my-node.lan")
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/distem/resource/pnode.rb', line 35 def initialize(hostname, ssh_user="root", ssh_password="") @id = @@ids begin @address = Resolv.getaddress(hostname) rescue Resolv::ResolvError raise Lib::InvalidParameterError, hostname end @cpu = CPU.new # mem and swap are stored in MB mem = `grep MemTotal /proc/meminfo`.gsub(/[^\d]/, '').to_i / 1024 swap = `grep SwapTotal /proc/meminfo`.gsub(/[^\d]/, '').to_i / 1024 @memory = Memory.new(mem, swap) @ssh_user = ssh_user @ssh_password = ssh_password @status = Status::INIT @algorithms = {} @algorithms[:cpu] = Algorithm::CPU::HOGS @@ids += 1 @local_vifaces = 0 end |
Instance Attribute Details
- (Object) address (readonly)
The IP address of the machine
12 13 14 |
# File 'lib/distem/resource/pnode.rb', line 12 def address @address end |
- (Object) algorithms
The emulation algorithms that are used on this physical node (Hash)
20 21 22 |
# File 'lib/distem/resource/pnode.rb', line 20 def algorithms @algorithms end |
- (Object) cpu
The machine's CPU description
14 15 16 |
# File 'lib/distem/resource/pnode.rb', line 14 def cpu @cpu end |
- (Object) id (readonly)
The unique id of the machine
10 11 12 |
# File 'lib/distem/resource/pnode.rb', line 10 def id @id end |
- (Object) local_vifaces
The number of local vifaces
22 23 24 |
# File 'lib/distem/resource/pnode.rb', line 22 def local_vifaces @local_vifaces end |
- (Object) memory
The machine's memory description
16 17 18 |
# File 'lib/distem/resource/pnode.rb', line 16 def memory @memory end |
- (Object) ssh_password (readonly)
Deprecated, used to contact the physical node if the SSH key file is not set
25 26 27 |
# File 'lib/distem/resource/pnode.rb', line 25 def ssh_password @ssh_password end |
- (Object) ssh_user (readonly)
Deprecated, used to contact the physical node if the SSH key file is not set
25 26 27 |
# File 'lib/distem/resource/pnode.rb', line 25 def ssh_user @ssh_user end |
- (Object) status
The status in which the Node is (see Status)
18 19 20 |
# File 'lib/distem/resource/pnode.rb', line 18 def status @status end |
Instance Method Details
- (Object) ==(pnode)
Compare two PNodes (based on the host address)
Returns
Boolean value
61 62 63 |
# File 'lib/distem/resource/pnode.rb', line 61 def ==(pnode) pnode.is_a?(PNode) and (@address == pnode.address) end |