Class: Distem::NetAPI::Client
- Inherits:
-
Object
- Object
- Distem::NetAPI::Client
- Defined in:
- lib/distem/netapi/client.rb
Overview
For desc
parameters, the only elements in the structure (Hash)
that will be taken in account are those listed as writable
in Resources Description.
Most of changes you can perform on virtual nodes resources are taking effect after stopping then starting back the resource. Changes that are applied on-the-fly are documented as this.
Distem ruby client
Constant Summary
- MAX_SIMULTANEOUS_REQ =
The maximum number of simultaneous requests
50
- HTTP_STATUS_OK =
The HTTP OK status value
200
- @@semreq =
Lib::Semaphore.new(MAX_SIMULTANEOUS_REQ)
Instance Method Summary (collapse)
-
- (Object) event_manager_start
Start the event manager.
-
- (Object) event_manager_stop
Stop the event manager and clear the event list.
-
- (Object) event_random_add(resource_desc, event_type, generator_desc, first_value = nil)
Add a random generated event to a resource.
-
- (Object) event_trace_add(resource_desc, event_type, trace)
Add an event trace to a resource.
-
- (Object) event_trace_file_add(resource_desc, event_type, trace_file)
Add an event trace to a resource from a file.
-
- (Object) event_trace_string_add(resource_desc, event_type, trace_string)
Add an event trace to a resource, but the source is a string.
-
- (Client) initialize(serveraddr = "localhost", port = 4567, semsize = nil)
constructor
Create a new Client and connect it to a specified REST(distem) server.
-
- (Hash) pcpu_info(target = 'localhost')
Retrieve information about the CPU of a physical node.
-
- (Hash) pmemory_info(target = 'localhost')
Retrieve information about the memory of a physical node.
-
- (Hash) pnode_info(target = 'localhost')
Retrieve informations about a physical node.
-
- (Hash) pnode_init(target = 'localhost', desc = {}, async = false)
Initialize a physical machine (launching daemon, creating cgroups, …).
-
- (Hash) pnode_init!(target = 'localhost', desc = {})
Asynchronious version of #pnode_init.
-
- (Hash) pnode_quit(target = 'localhost')
Quit distem on a physical machine.
-
- (Hash) pnode_update(target = 'localhost', desc = {})
Update the physical node.
-
- (Object) pnodes_delete_probes
Delete the probes on the pnodes.
-
- (Hash) pnodes_get_probes_data
Get the data generated by the probes.
-
- (Array) pnodes_info
Retrieve informations about every physical nodes currently set on the platform.
-
- (Object) pnodes_launch_probes(desc, ref_time = nil)
Launch a set of probes on the pnodes.
-
- (Array) pnodes_quit
Quit distem on every physical machine.
-
- (Object) pnodes_restart_probes
Restart the probes on the pnodes.
-
- (Object) pnodes_stop_probes
Stop the probes on the pnodes.
- - (Object) PUT '/vnodes'
-
- (Object) set_global_arptable(data = nil, arp_file = nil)
Fill the ARP tables of all the Vnodes.
-
- (Object) set_global_etchosts(data = nil)
Create a global /etc/hosts on every Vnodes.
-
- (Object) set_peers_latencies(vnodes, matrix)
Configure latencies of peers from a matrix.
-
- (Hash) vcpu_create(vnodename, val, unit = 'mhz', corenb = 1)
Set up a virtual CPU on the virtual node.
-
- (Hash) vcpu_info(vnodename)
Retrive information about a virtual node CPU.
-
- (Hash) vcpu_remove(vnodename)
Removing a virtual CPU on the virtual node.
-
- (Hash) vcpu_update(vnodename, val, unit = 'mhz')
Update a virtual CPU on the virtual node.
-
- (Hash) vfilesystem_create(vnodename, desc)
Set up the filesystem of a virtual node.
-
- (String) vfilesystem_image(vnodename, target = '.')
Retrieve compressed image (tgz) of the filesystem of a node.
-
- (Hash) vfilesystem_info(vnodename)
Retrieve informations about a virtual node filesystem.
-
- (Hash) vfilesystem_update(vnodename, desc)
Update the filesystem of a virtual node.
-
- (Hash) viface_create(vnodename, name, desc)
Create a virtual network interface on the virtual node.
-
- (Hash) viface_info(vnodename, vifacename)
Retrieve informations about a virtual network interface associated to a virtual node.
-
- (Hash) viface_remove(vnodename, vifacename)
Remove a virtual network interface.
-
- (Hash) viface_update(vnodename, vifacename, desc = {})
Update a virtual network interface.
-
- (Hash) vinput_info(vnodename, vifacename)
Retrive the traffic description on the input of a specified virtual network interface.
-
- (Hash) vinput_update(vnodename, vifacename, desc = {})
Update the traffic description on the input of a specified virtual network interface.
-
- (Hash) vmem_create(vnodename, mem, swap = nil)
Create a new memory limitation.
-
- (Hash) vnetwork_create(name, address, opts = nil)
Create a new virtual network.
-
- (Object) vnetwork_create_routing_interface(address, netmask)
Create a routing interface on a PNode (Should not be called directly).
-
- (Hash) vnetwork_info(vnetname)
Retrieve informations about a virtual network.
-
- (Hash) vnetwork_remove(vnetname)
Remove a virtual network, that will disconnect every virtual node connected on it and remove it's virtual routes.
-
- (Array) vnetworks_info
Retrieve informations about every virtual network currently set on the platform.
-
- (Array) vnetworks_remove
Remove every virtual network.
-
- (Hash) vnode_create(name, desc = {}, ssh_key = {}, async = false)
Create a new virtual node.
-
- (String) vnode_execute(vnodename, command)
Execute and get the result of a command on a virtual node.
-
- (Hash) vnode_freeze(vnodename, async = false)
Freeze a virtual node, but without deleting its data.
-
- (Hash) vnode_info(vnodename)
Retrieve informations about a virtual node.
-
- (Hash) vnode_mode(vnodename, gateway = true)
Set the mode of a virtual node.
-
- (Hash) vnode_remove(vnodename)
Remove the virtual node.
-
- (Hash) vnode_start(vnodename, async = false)
Start a virtual node.
-
- (Hash) vnode_start!(vnodename)
Same as #vnode_start but in asynchronious mode.
-
- (Hash) vnode_stop(vnodename, async = false)
Stopping a virtual node, deleting it's data from the hosting physical node.
-
- (Hash) vnode_stop!(vnodename)
Same as #vnode_stop but in asynchronious mode.
-
- (Hash) vnode_unfreeze(vnodename, async = false)
Unfreeze a virtual node, but without deleting its data.
-
- (Hash) vnode_update(vnodename, desc = {}, async = false)
Update a virtual node description.
-
- (Array) vnodes_create(names, desc = {}, ssh_key = {}, async = false)
Create new virtual nodes.
-
- (Hash) vnodes_execute(names, command)
Execute and get the result of a command on a set of virtual nodes.
-
- (Array) vnodes_freeze(names = nil, async = false)
Freeze some virtual nodes.
-
- (Array) vnodes_info
Retrieve informations about every virtual nodes currently set on the platform.
-
- (Array) vnodes_remove(names = nil)
Remove the virtual vnodes, or every if names is nil.
-
- (Hash) vnodes_start(names, async = false)
Start several virtual nodes.
-
- (Hash) vnodes_start!(names)
Same as #vnodes_start but in asynchronious mode.
-
- (Hash) vnodes_stop(names = nil, async = false)
Stop given virtal nodes.
-
- (Array) vnodes_unfreeze(names = nil, async = false)
Unfreeze some virtual nodes.
-
- (Hash) vnodes_update(name, desc = {}, async = false)
Update several virtual node descriptions.
-
- (Hash) voutput_info(vnodename, vifacename)
Retrive the traffic description on the output of a specified virtual network interface.
-
- (Hash) voutput_update(vnodename, vifacename, desc = {})
Update the traffic description on the output of a specified virtual network interface.
-
- (Hash) vplatform_create(data, format = 'JSON', rootfs = nil)
Create an set a platform with backup data.
-
- (String) vplatform_info
Get the full description of the platform.
-
- (Array) vroute_complete
Create all possible virtual routes between all the virtual networks, automagically choosing the virtual nodes to use as gateways.
-
- (Hash) vroute_create(srcnet, dstnet, gateway)
Create a new virtual route between two virtual networks (“ is accessible from using ”).
-
- (Object) wait_vnodes(opts = {})
Wait a set of vnodes (or all) by checking that a given port (22 by default) is open.
Constructor Details
- (Client) initialize(serveraddr = "localhost", port = 4567, semsize = nil)
Create a new Client and connect it to a specified REST(distem) server
36 37 38 39 40 41 42 |
# File 'lib/distem/netapi/client.rb', line 36 def initialize(serveraddr="localhost",port=4567, semsize = nil) raise unless port.is_a?(Numeric) @serveraddr = serveraddr @serverurl = 'http://' + @serveraddr + ':' + port.to_s @resource = RestClient::Resource.new(@serverurl, :timeout => 9999, :open_timeout => 9999) @@semreq = Lib::Semaphore.new(semsize) if semsize and @@semreq.size != semsize end |
Instance Method Details
- (Object) event_manager_start
Start the event manager
651 652 653 |
# File 'lib/distem/netapi/client.rb', line 651 def event_manager_start post_json("/eventmanager", {}) end |
- (Object) event_manager_stop
Stop the event manager and clear the event list
656 657 658 |
# File 'lib/distem/netapi/client.rb', line 656 def event_manager_stop delete_json("/eventmanager") end |
- (Object) event_random_add(resource_desc, event_type, generator_desc, first_value = nil)
Add a random generated event to a resource
641 642 643 644 645 646 647 648 |
# File 'lib/distem/netapi/client.rb', line 641 def event_random_add(resource_desc, event_type, generator_desc, first_value = nil) params = {} params['resource'] = resource_desc params['event_type'] = event_type params['generator'] = generator_desc params['first_value'] = first_value if first_value post_json("/events/random", params) end |
- (Object) event_trace_add(resource_desc, event_type, trace)
Add an event trace to a resource
614 615 616 617 618 619 620 |
# File 'lib/distem/netapi/client.rb', line 614 def event_trace_add(resource_desc, event_type, trace) params = {} params['resource'] = resource_desc params['event_type'] = event_type params['trace'] = trace post_json("/events/trace", params) end |
- (Object) event_trace_file_add(resource_desc, event_type, trace_file)
Add an event trace to a resource from a file
632 633 634 635 636 637 638 |
# File 'lib/distem/netapi/client.rb', line 632 def event_trace_file_add(resource_desc, event_type, trace_file) params = {} params['resource'] = resource_desc params['event_type'] = event_type params['trace_string'] = IO.read(trace_file) post_json("/events/trace_string", params) end |
- (Object) event_trace_string_add(resource_desc, event_type, trace_string)
Add an event trace to a resource, but the source is a string
623 624 625 626 627 628 629 |
# File 'lib/distem/netapi/client.rb', line 623 def event_trace_string_add(resource_desc, event_type, trace_string) params = {} params['resource'] = resource_desc params['event_type'] = event_type params['trace_string'] = trace_string post_json("/events/trace_string", params) end |
- (Hash) pcpu_info(target = 'localhost')
Retrieve information about the CPU of a physical node
136 137 138 |
# File 'lib/distem/netapi/client.rb', line 136 def pcpu_info(target='localhost') get_json("/pnodes/#{target}/cpu") end |
- (Hash) pmemory_info(target = 'localhost')
Retrieve information about the memory of a physical node
144 145 146 |
# File 'lib/distem/netapi/client.rb', line 144 def pmemory_info(target='localhost') get_json("/pnodes/#{target}/memory") end |
- (Hash) pnode_info(target = 'localhost')
Retrieve informations about a physical node
83 84 85 |
# File 'lib/distem/netapi/client.rb', line 83 def pnode_info(target='localhost') get_json("/pnodes/#{target}") end |
- (Hash) pnode_init(target = 'localhost', desc = {}, async = false)
Initialize a physical machine (launching daemon, creating cgroups, …). This step have to be performed to be able to create virtual nodes on a machine.
51 52 53 |
# File 'lib/distem/netapi/client.rb', line 51 def pnode_init(target = 'localhost', desc = {}, async=false) post_json("/pnodes", { :target => target, :desc => desc, :async => async }) end |
- (Hash) pnode_init!(target = 'localhost', desc = {})
Asynchronious version of #pnode_init.
58 59 60 |
# File 'lib/distem/netapi/client.rb', line 58 def pnode_init!(target = 'localhost', desc = {}) return pnode_init(target,desc,true) end |
- (Hash) pnode_quit(target = 'localhost')
Quit distem on a physical machine
66 67 68 |
# File 'lib/distem/netapi/client.rb', line 66 def pnode_quit(target='localhost') delete_json("/pnodes/#{target}") end |
- (Hash) pnode_update(target = 'localhost', desc = {})
Update the physical node
75 76 77 |
# File 'lib/distem/netapi/client.rb', line 75 def pnode_update(target='localhost', desc={}) put_json("/pnodes/#{CGI.escape(target)}", { :desc => desc }) end |
- (Object) pnodes_delete_probes
Delete the probes on the pnodes
121 122 123 |
# File 'lib/distem/netapi/client.rb', line 121 def pnodes_delete_probes() delete_json("/pnodes/probes") end |
- (Hash) pnodes_get_probes_data
Get the data generated by the probes
128 129 130 |
# File 'lib/distem/netapi/client.rb', line 128 def pnodes_get_probes_data() return get_json("/pnodes/probes") end |
- (Array) pnodes_info
Retrieve informations about every physical nodes currently set on the platform
97 98 99 |
# File 'lib/distem/netapi/client.rb', line 97 def pnodes_info() get_json("/pnodes") end |
- (Object) pnodes_launch_probes(desc, ref_time = nil)
Launch a set of probes on the pnodes
104 105 106 107 108 |
# File 'lib/distem/netapi/client.rb', line 104 def pnodes_launch_probes(desc, ref_time = nil) params = { :desc => desc } params[:ref_time] = ref_time if ref_time post_json("/pnodes/probes", params) end |
- (Array) pnodes_quit
Quit distem on every physical machine
90 91 92 |
# File 'lib/distem/netapi/client.rb', line 90 def pnodes_quit() delete_json("/pnodes") end |
- (Object) pnodes_restart_probes
Restart the probes on the pnodes
111 112 113 |
# File 'lib/distem/netapi/client.rb', line 111 def pnodes_restart_probes() put_json("/pnodes/probes", { :state => 'restart'}) end |
- (Object) pnodes_stop_probes
Stop the probes on the pnodes
116 117 118 |
# File 'lib/distem/netapi/client.rb', line 116 def pnodes_stop_probes() put_json("/pnodes/probes", { :state => 'stop'}) end |
- (Object) PUT '/vnodes'
212 |
# File 'lib/distem/netapi/client.rb', line 212 put('/vnodes', { :name => name, :desc => desc, :async => async, :type => 'update' }) |
- (Object) set_global_arptable(data = nil, arp_file = nil)
Fill the ARP tables of all the Vnodes
694 695 696 697 698 699 |
# File 'lib/distem/netapi/client.rb', line 694 def set_global_arptable(data = nil, arp_file = nil) params = {} params['data'] = data if data params['arp_file'] = arp_file if arp_file post_json("/global_arptable", params) end |
- (Object) set_global_etchosts(data = nil)
Create a global /etc/hosts on every Vnodes
674 675 676 677 678 |
# File 'lib/distem/netapi/client.rb', line 674 def set_global_etchosts(data = nil) params = {} params['data'] = data if data post_json("/global_etchosts", params) end |
- (Object) set_peers_latencies(vnodes, matrix)
Configure latencies of peers from a matrix
664 665 666 667 668 669 |
# File 'lib/distem/netapi/client.rb', line 664 def set_peers_latencies(vnodes, matrix) params = {} params['vnodes'] = vnodes params['matrix'] = matrix post_json("/peers_matrix_latencies", params) end |
- (Hash) vcpu_create(vnodename, val, unit = 'mhz', corenb = 1)
Set up a virtual CPU on the virtual node
450 451 452 453 |
# File 'lib/distem/netapi/client.rb', line 450 def vcpu_create(vnodename, val, unit='mhz', corenb=1) desc = { :corenb => corenb, :val => val, :unit => unit } post_json("/vnodes/#{CGI.escape(vnodename)}/cpu", { :desc => desc }) end |
- (Hash) vcpu_info(vnodename)
Retrive information about a virtual node CPU
477 478 479 |
# File 'lib/distem/netapi/client.rb', line 477 def vcpu_info(vnodename) get_json("/vnodes/#{CGI.escape(vnodename)}/cpu") end |
- (Hash) vcpu_remove(vnodename)
Removing a virtual CPU on the virtual node
470 471 472 |
# File 'lib/distem/netapi/client.rb', line 470 def vcpu_remove(vnodename) delete_json("/vnodes/#{CGI.escape(vnodename)}/cpu") end |
- (Hash) vcpu_update(vnodename, val, unit = 'mhz')
This setting works on-the-fly (i.e. even if the virtual node is already running)
Update a virtual CPU on the virtual node
461 462 463 464 |
# File 'lib/distem/netapi/client.rb', line 461 def vcpu_update(vnodename, val, unit='mhz') desc = { :val => val, :unit => unit } put_json("/vnodes/#{CGI.escape(vnodename)}/cpu", { :desc => desc }) end |
- (Hash) vfilesystem_create(vnodename, desc)
Set up the filesystem of a virtual node
486 487 488 |
# File 'lib/distem/netapi/client.rb', line 486 def vfilesystem_create(vnodename,desc) post_json("/vnodes/#{CGI.escape(vnodename)}/filesystem", { :desc => desc }) end |
- (String) vfilesystem_image(vnodename, target = '.')
Retrieve compressed image (tgz) of the filesystem of a node.
512 513 514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/distem/netapi/client.rb', line 512 def vfilesystem_image(vnodename,target = '.') target = '.' if !target raise Lib::ResourceNotFoundError, File.dirname(target) unless File.exist?(File.dirname(target)) if File.directory?(target) target = File.join(target,"#{vnodename}-fsimage.tar.gz") end content = get_content("/vnodes/#{CGI.escape(vnodename)}/filesystem/image") File.open(target, 'w') { |f| f.syswrite(content) } target end |
- (Hash) vfilesystem_info(vnodename)
Retrieve informations about a virtual node filesystem
503 504 505 |
# File 'lib/distem/netapi/client.rb', line 503 def vfilesystem_info(vnodename) get_json("/vnodes/#{CGI.escape(vnodename)}/filesystem") end |
- (Hash) vfilesystem_update(vnodename, desc)
Update the filesystem of a virtual node
495 496 497 |
# File 'lib/distem/netapi/client.rb', line 495 def vfilesystem_update(vnodename,desc) put_json("/vnodes/#{CGI.escape(vnodename)}/filesystem", { :desc => desc }) end |
- (Hash) viface_create(vnodename, name, desc)
Create a virtual network interface on the virtual node
367 368 369 |
# File 'lib/distem/netapi/client.rb', line 367 def viface_create(vnodename, name, desc) post_json("/vnodes/#{CGI.escape(vnodename)}/ifaces", { :name => name, :desc => desc }) end |
- (Hash) viface_info(vnodename, vifacename)
Retrieve informations about a virtual network interface associated to a virtual node
439 440 441 |
# File 'lib/distem/netapi/client.rb', line 439 def viface_info(vnodename, vifacename) get_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}") end |
- (Hash) viface_remove(vnodename, vifacename)
Remove a virtual network interface
376 377 378 |
# File 'lib/distem/netapi/client.rb', line 376 def viface_remove(vnodename,vifacename) delete_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}") end |
- (Hash) viface_update(vnodename, vifacename, desc = {})
Disconnect (detach) the virtual network interface from any virtual network
it's connected on if desc
is empty
Update a virtual network interface
388 389 390 |
# File 'lib/distem/netapi/client.rb', line 388 def viface_update(vnodename, vifacename, desc = {}) put_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}", { :desc => desc }) end |
- (Hash) vinput_info(vnodename, vifacename)
Retrive the traffic description on the input of a specified virtual network interface
409 410 411 |
# File 'lib/distem/netapi/client.rb', line 409 def vinput_info(vnodename, vifacename) get_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}/input") end |
- (Hash) vinput_update(vnodename, vifacename, desc = {})
The vtraffic description is updated on-the-fly (even if the virtual node is running)
Reset the vtraffic description if desc
is empty
Update the traffic description on the input of a specified virtual network interface
400 401 402 |
# File 'lib/distem/netapi/client.rb', line 400 def vinput_update(vnodename, vifacename, desc = {}) put_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}/input", { :desc => desc }) end |
- (Hash) vmem_create(vnodename, mem, swap = nil)
Create a new memory limitation
685 686 687 688 |
# File 'lib/distem/netapi/client.rb', line 685 def vmem_create(vnodename, mem, swap = nil) desc = { :mem => mem, :swap => swap} post_json("/vnodes/#{CGI.escape(vnodename)}/vmem", { :desc => desc }) end |
- (Hash) vnetwork_create(name, address, opts = nil)
Create a new virtual network
532 533 534 535 536 |
# File 'lib/distem/netapi/client.rb', line 532 def vnetwork_create(name, address, opts = nil) desc = { :name => name, :address => address } desc[:opts] = opts if opts post_json('/vnetworks', desc) end |
- (Object) vnetwork_create_routing_interface(address, netmask)
Create a routing interface on a PNode (Should not be called directly)
541 542 543 |
# File 'lib/distem/netapi/client.rb', line 541 def vnetwork_create_routing_interface(address, netmask) put_json('/vnetworks', {:address => address, :netmask => netmask}) end |
- (Hash) vnetwork_info(vnetname)
Retrieve informations about a virtual network
557 558 559 |
# File 'lib/distem/netapi/client.rb', line 557 def vnetwork_info(vnetname) get_json("/vnetworks/#{CGI.escape(vnetname)}") end |
- (Hash) vnetwork_remove(vnetname)
Remove a virtual network, that will disconnect every virtual node connected on it and remove it's virtual routes.
549 550 551 |
# File 'lib/distem/netapi/client.rb', line 549 def vnetwork_remove(vnetname) delete_json("/vnetworks/#{CGI.escape(vnetname)}") end |
- (Array) vnetworks_info
Retrieve informations about every virtual network currently set on the platform
570 571 572 |
# File 'lib/distem/netapi/client.rb', line 570 def vnetworks_info() get_json("/vnetworks") end |
- (Array) vnetworks_remove
Remove every virtual network
564 565 566 |
# File 'lib/distem/netapi/client.rb', line 564 def vnetworks_remove() delete_json("/vnetworks") end |
- (Hash) vnode_create(name, desc = {}, ssh_key = {}, async = false)
Create a new virtual node
163 164 165 |
# File 'lib/distem/netapi/client.rb', line 163 def vnode_create(name, desc = {}, ssh_key={}, async=false) post_json("/vnodes/#{CGI.escape(name)}", { :desc => desc, :ssh_key => ssh_key, :async => async }) end |
- (String) vnode_execute(vnodename, command)
Execute and get the result of a command on a virtual node
348 349 350 |
# File 'lib/distem/netapi/client.rb', line 348 def vnode_execute(vnodename, command) post_json("/vnodes/#{CGI.escape(vnodename)}/commands", { :command => command }) end |
- (Hash) vnode_freeze(vnodename, async = false)
Freeze a virtual node, but without deleting its data
296 297 298 |
# File 'lib/distem/netapi/client.rb', line 296 def vnode_freeze(vnodename, async=false) put_json("/vnodes/#{CGI.escape(vnodename)}", { :async => async, :type => 'freeze'}) end |
- (Hash) vnode_info(vnodename)
Retrieve informations about a virtual node
219 220 221 |
# File 'lib/distem/netapi/client.rb', line 219 def vnode_info(vnodename) get_json("/vnodes/#{CGI.escape(vnodename)}") end |
- (Hash) vnode_mode(vnodename, gateway = true)
Set the mode of a virtual node
331 332 333 334 |
# File 'lib/distem/netapi/client.rb', line 331 def vnode_mode(vnodename,gateway=true) desc = { :mode => gateway ? Resource::VNode::MODE_GATEWAY : Resource::VNode::MODE_NORMAL } put_json("/vnodes/#{CGI.escape(vnodename)}", { :desc => desc, :type => 'update' }) end |
- (Hash) vnode_remove(vnodename)
“Cascade” removing: remove all the vroutes in which this virtual node apears as gateway
Remove the virtual node
182 183 184 |
# File 'lib/distem/netapi/client.rb', line 182 def vnode_remove(vnodename) put_json("/vnodes/#{CGI.escape(vnodename)}", { :type => 'remove'}) end |
- (Hash) vnode_start(vnodename, async = false)
A physical node (that have enought physical resources (CPU,…)) will be
automatically allocated if there is none set as host
at the
moment
The filesystem archive will be copied on the hosting physical node.
A filesystem image must have been set (see #vnode_create or #vfilesystem_create/#vfilesystem_update).
Start a virtual node.
232 233 234 235 |
# File 'lib/distem/netapi/client.rb', line 232 def vnode_start(vnodename, async=false) desc = { :status => Resource::Status::RUNNING } put_json("/vnodes/#{CGI.escape(vnodename)}", { :desc => desc, :async => async, :type => 'update' }) end |
- (Hash) vnode_start!(vnodename)
Same as #vnode_start but in asynchronious mode
240 241 242 |
# File 'lib/distem/netapi/client.rb', line 240 def vnode_start!(vnodename) return vnode_start(vnodename,true) end |
- (Hash) vnode_stop(vnodename, async = false)
The host
association for this virtual node will be cancelled,
if you start the virtual node directcly after stopping it, the hosting
physical node will be chosen randomly (to set it manually, see host field,
#vnode_update)
Stopping a virtual node, deleting it's data from the hosting physical node.
271 272 273 274 |
# File 'lib/distem/netapi/client.rb', line 271 def vnode_stop(vnodename, async=false) desc = { :status => Resource::Status::DOWN } put_json("/vnodes/#{CGI.escape(vnodename)}", { :desc => desc, :async => async, :type => 'stop' }) end |
- (Hash) vnode_stop!(vnodename)
Same as #vnode_stop but in asynchronious mode
279 280 281 |
# File 'lib/distem/netapi/client.rb', line 279 def vnode_stop!(vnodename) return vnode_stop(vnodename, true) end |
- (Hash) vnode_unfreeze(vnodename, async = false)
Unfreeze a virtual node, but without deleting its data
314 315 316 |
# File 'lib/distem/netapi/client.rb', line 314 def vnode_unfreeze(vnodename, async=false) put_json("/vnodes/#{CGI.escape(vnodename)}", { :async => async, :type => 'unfreeze'}) end |
- (Hash) vnode_update(vnodename, desc = {}, async = false)
Update a virtual node description
201 202 203 |
# File 'lib/distem/netapi/client.rb', line 201 def vnode_update(vnodename, desc = {}, async=false) put_json("/vnodes/#{CGI.escape(vnodename)}", { :desc => desc, :async => async, :type => 'update' }) end |
- (Array) vnodes_create(names, desc = {}, ssh_key = {}, async = false)
Create new virtual nodes
173 174 175 |
# File 'lib/distem/netapi/client.rb', line 173 def vnodes_create(names, desc = {}, ssh_key={}, async=false) post_json('/vnodes', { :names => names , :desc => desc, :ssh_key => ssh_key, :async => async }) end |
- (Hash) vnodes_execute(names, command)
Execute and get the result of a command on a set of virtual nodes
357 358 359 |
# File 'lib/distem/netapi/client.rb', line 357 def vnodes_execute(names, command) post_json("/commands", { :names => names, :command => command }) end |
- (Array) vnodes_freeze(names = nil, async = false)
Freeze some virtual nodes
305 306 307 |
# File 'lib/distem/netapi/client.rb', line 305 def vnodes_freeze(names = nil, async=false) put_json("/vnodes", { :names => names, :async => async, :type => 'freeze' }) end |
- (Array) vnodes_info
Retrieve informations about every virtual nodes currently set on the platform
339 340 341 |
# File 'lib/distem/netapi/client.rb', line 339 def vnodes_info() get_json("/vnodes") end |
- (Array) vnodes_remove(names = nil)
Remove the virtual vnodes, or every if names is nil
189 190 191 192 193 |
# File 'lib/distem/netapi/client.rb', line 189 def vnodes_remove(names = nil) params = { :type => 'remove'} params[:names] = names if names put_json("/vnodes", params) end |
- (Hash) vnodes_start(names, async = false)
A physical node (that have enought physical resources (CPU,…)) will be
automatically allocated if there is none set as host
at the
moment
The filesystem archive will be copied on the hosting physical node.
A filesystem image must have been set (see #vnode_create or #vfilesystem_create/#vfilesystem_update).
Start several virtual nodes
253 254 255 256 |
# File 'lib/distem/netapi/client.rb', line 253 def vnodes_start(names, async=false) desc = { :status => Resource::Status::RUNNING } put_json('/vnodes', { :names => names , :desc => desc, :async => async, :type => 'update' }) end |
- (Hash) vnodes_start!(names)
Same as #vnodes_start but in asynchronious mode
261 262 263 |
# File 'lib/distem/netapi/client.rb', line 261 def vnodes_start!(names) return vnodes_start(names,true) end |
- (Hash) vnodes_stop(names = nil, async = false)
Stop given virtal nodes
287 288 289 |
# File 'lib/distem/netapi/client.rb', line 287 def vnodes_stop(names = nil, async=false) put_json("/vnodes", { :names => names, :async => async, :type => 'stop' }) end |
- (Array) vnodes_unfreeze(names = nil, async = false)
Unfreeze some virtual nodes
323 324 325 |
# File 'lib/distem/netapi/client.rb', line 323 def vnodes_unfreeze(names = nil, async=false) put_json("/vnodes", { :names => names, :async => async, :type => 'unfreeze' }) end |
- (Hash) vnodes_update(name, desc = {}, async = false)
Update several virtual node descriptions
211 212 213 |
# File 'lib/distem/netapi/client.rb', line 211 def vnodes_update(name, desc = {}, async=false) put('/vnodes', { :name => name, :desc => desc, :async => async, :type => 'update' }) end |
- (Hash) voutput_info(vnodename, vifacename)
Retrive the traffic description on the output of a specified virtual network interface
430 431 432 |
# File 'lib/distem/netapi/client.rb', line 430 def voutput_info(vnodename, vifacename) get_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}/output") end |
- (Hash) voutput_update(vnodename, vifacename, desc = {})
The vtraffic description is updated on-the-fly (even if the virtual node is running)
Reset the vtraffic description if desc
is empty
Update the traffic description on the output of a specified virtual network interface
421 422 423 |
# File 'lib/distem/netapi/client.rb', line 421 def voutput_update(vnodename, vifacename, desc = {}) put_json("/vnodes/#{CGI.escape(vnodename)}/ifaces/#{CGI.escape(vifacename)}/output", { :desc => desc }) end |
- (Hash) vplatform_create(data, format = 'JSON', rootfs = nil)
Create an set a platform with backup data
597 598 599 |
# File 'lib/distem/netapi/client.rb', line 597 def vplatform_create(data,format = 'JSON',rootfs = nil) post_json("/vplatform", { 'format' => format, 'data' => data, 'rootfs' => rootfs }) end |
- (String) vplatform_info
Get the full description of the platform
604 605 606 607 |
# File 'lib/distem/netapi/client.rb', line 604 def vplatform_info() ret = get_json("/vplatform") return JSON.pretty_generate(ret) end |
- (Array) vroute_complete
Create all possible virtual routes between all the virtual networks, automagically choosing the virtual nodes to use as gateways
588 589 590 |
# File 'lib/distem/netapi/client.rb', line 588 def vroute_complete() post_json("/vnetworks/routes/complete", { }) end |
- (Hash) vroute_create(srcnet, dstnet, gateway)
Create a new virtual route between two virtual networks (“<dstnet> is accessible from <srcnet> using <gateway>”)
580 581 582 583 |
# File 'lib/distem/netapi/client.rb', line 580 def vroute_create(srcnet,dstnet,gateway) post_json("/vnetworks/#{CGI.escape(srcnet)}/routes", { :destnetwork => dstnet, :gatewaynode => gateway }) end |
- (Object) wait_vnodes(opts = {})
Wait a set of vnodes (or all) by checking that a given port (22 by default) is open. Should not be used directly after vnode_start! or vnodes_start!
705 706 707 |
# File 'lib/distem/netapi/client.rb', line 705 def wait_vnodes(opts = {}) return (post_json('/wait_vnodes', {'opts' => opts}) == ['true']) end |