Class: Exec::ClusterCreate
- Inherits:
-
ExecutableCommand
- Object
- ExecutableCommand
- Exec::ClusterCreate
- Defined in:
- lib/exec/cluster_create.rb
Overview
Allows the user to create a cluster
Instance Attribute Summary collapse
-
#network_address ⇒ Object
readonly
Returns the value of attribute network_address.
-
#vlan_id ⇒ Object
readonly
Returns the value of attribute vlan_id.
Attributes inherited from ExecutableCommand
#argv, #command_name, #logger, #options, #stderr, #stdin, #stdout, #values
Instance Method Summary collapse
-
#exec ⇒ Object
The execution of the command.
-
#initialize(argv, stdin, stdout, stderr, command_name) ⇒ ClusterCreate
constructor
Default constructor of the class.
-
#set_options ⇒ Object
private
Parse and check the parameters of the function.
Methods inherited from ExecutableCommand
#check_parameters, #create_logger, #run
Constructor Details
#initialize(argv, stdin, stdout, stderr, command_name) ⇒ ClusterCreate
Note:
Overrides default constructor by passing CustomCommandOption to super().
Default constructor of the class.
27 28 29 |
# File 'lib/exec/cluster_create.rb', line 27 def initialize(argv, stdin, stdout, stderr, command_name) super(argv, stdin, stdout, stderr, command_name) end |
Instance Attribute Details
#network_address ⇒ Object (readonly)
Returns the value of attribute network_address.
20 21 22 |
# File 'lib/exec/cluster_create.rb', line 20 def network_address @network_address end |
#vlan_id ⇒ Object (readonly)
Returns the value of attribute vlan_id.
21 22 23 |
# File 'lib/exec/cluster_create.rb', line 21 def vlan_id @vlan_id end |
Instance Method Details
#exec ⇒ Object
The execution of the command.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/exec/cluster_create.rb', line 46 def exec @logger.info("Exec::ClusterCreate Executing ClusterCreate") @logger.info("Exec::ClusterCreate Create the vcluster '#{@values['cluster']}'...") Color::print_log("NONE", "Create the vcluster '#{@values['cluster']}'...", @stdout) default_cpu = 1024 default_ram= "1g" cluster_name = @values['cluster'] @network_address = values['address'] address = @values['address'].split('/').first cidr = @values['address'].split('/').last if cidr == "8" network_mask="255.0.0.0" elsif cidr == "16" network_mask="255.255.0.0" else network_mask="255.255.255.0" end if @values['cpu_weight'].nil? cpu_weight = default_cpu else cpu_weight = @values['cpu_weight'] end if @values['ram'].nil? ram = default_ram else ram = @values['ram'] end unless @values['vlan_id'].nil? @vlan_id = values['vlan_id'] end if @values['description'].nil? description = "" else description = @values['description'] end output = "" cmd = Command::ClusterCreate.new(cluster_name, address, network_mask, cpu_weight, ram, @vlan_id, description) output += cmd.exec() cmd = Command::.new(cluster_name) cmd.exec() Color::echo_ok(@stdout) @stdout.print output end |
#set_options ⇒ Object (private)
Parse and check the parameters of the function.
34 35 36 37 38 39 40 41 |
# File 'lib/exec/cluster_create.rb', line 34 def .add_option("a", "address", "the adress Network and the cidr of the Cluster.", true, true, method(:check_network_address)) .add_option("C", "cluster", "The name of the vcluster .", true, true, method(:check_cluster_name)) .add_option("c", "cpu_weight", "CPU weight for each node in the virtual cluster .", false, true, method(:check_cpu_weight)) .add_option("d", "description", "Description of the cluster (put quotes).", false, true) .add_option("i", "vlan_id", "Id VLAN.", false, true, method(:check_vlan_id)) .add_option("r", "ram", "Min ram assigned for each node in the virtual cluster.", false, true, method(:check_ram_size)) end |