Hi all,
I am struck at this point and needed some help in ruby
I wanted to write a script that accepts the no of VNICs the user wants to create and
then ask for the name of each Vnic he wants
then use these names to create the corresponding Vnics
Eg: suppose that there are 2 Vnics to be created
Then the user should be asked for the names of these and upon entering the names the corresponding ones are created
PS: this is actually a part of the wrapper script that i am struck with!
The command to create the Vnic is already present(in solaris,Crossbow) i just need to know how to include the names provided by the user into the command so that the job is done!
This is what i came up with
Code:
#!/usr/bin/ruby
class Etherstub
def initialize
@estub ; @stub_name
@vni
end
def ether_create
puts "enter the no of stubs you want"
@estub = gets ;puts "Enter the names 1 by 1 "
@estub.to_i.times {|@stub_name| ;@stub_name = gets }
@estub.to_i.times { puts `/usr/sbin/dladm create-etherstub #{@stub_name}
` }
print "Stub created!!"
end
end
first = Etherstub.new
first.ether_create
This is the error i get
Code:
enter the no of stubs you want
2
Enter the names 1 by 1
etherstub1
etherstub2
/usr/sbin/dladm: etherstub creation failed: object already exists
This is only creating 1 stub that too etherstub2 and not etherstub1
(I have checked it out)
I would like to know where am going wrong?
Thanks