class CollinsShell::IpAddress
Public Class Methods
Public Instance Methods
allocate(pool)
click to toggle source
# File lib/collins_shell/ip_address.rb, line 21 def allocate pool call_collins get_collins_client, "ip_address allocate" do |client| addresses = client.ipaddress_allocate! options.tag, pool, options["count"] header = [["Gateway","Netmask","Address","Pool"]] tags = header + addresses.map do |address| [address.gateway, address.netmask, address.address, address.pool] end print_table tags end end
assets(pool)
click to toggle source
# File lib/collins_shell/ip_address.rb, line 68 def assets pool call_collins get_collins_client, "ip_address assets" do |client| header = true client.assets_in_pool(pool).each do |asset| if options.details then asset = client.get asset print_find_results asset, [:tag,:status,:type,:hostname,:addresses], :header => header header = false else puts(asset.tag) end end end end
create()
click to toggle source
# File lib/collins_shell/ip_address.rb, line 105 def create call_collins get_collins_client, "create address" do |client| address = client.ipaddress_update! options.tag, nil, :address => options.address, :gateway => options.gateway, :netmask => options.netmask, :pool => options.pool if address then say_success "Address for #{options.tag} created" else say_error "Address for #{options.tag} not created" end end end
delete(pool)
click to toggle source
# File lib/collins_shell/ip_address.rb, line 35 def delete pool call_collins get_collins_client, "ip_address delete" do |client| delete_count = client.ipaddress_delete! options.tag, pool say_success "Deleted #{delete_count} addresses" end end
delete_all()
click to toggle source
# File lib/collins_shell/ip_address.rb, line 45 def delete_all call_collins get_collins_client, "ip_address delete_all" do |client| delete_count = client.ipaddress_delete! options.tag say_success "Deleted #{delete_count} addresses" end end
find(address)
click to toggle source
# File lib/collins_shell/ip_address.rb, line 54 def find address call_collins get_collins_client, "ip_address find" do |client| asset = client.asset_at_address address if asset then say_success "Asset #{asset.tag} is using address #{address}" else say_error "No asset using address #{address}" end end end
pools()
click to toggle source
# File lib/collins_shell/ip_address.rb, line 86 def pools call_collins get_collins_client, "ip_address pools" do |client| # NAME, NETWORK, START_ADDRESS, SPECIFIED_GATEWAY, GATEWAY, BROADCAST, POSSIBLE_ADDRESSES header = [["Pool","Network","Gateway","Broadcast","Possible Addresses","Start Address","Specified Gateway"]] rows = client.ipaddress_pools(!options.used).map do |pool| [pool["NAME"], pool["NETWORK"], pool["GATEWAY"], pool["BROADCAST"], pool["POSSIBLE_ADDRESSES"], pool["START_ADDRESS"], pool["SPECIFIED_GATEWAY"]] end print_table header + rows end end
update(old_address)
click to toggle source
# File lib/collins_shell/ip_address.rb, line 127 def update old_address call_collins get_collins_client, "update address" do |client| address = client.ipaddress_update! options.tag, old_address, :address => options.address, :gateway => options.gateway, :netmask => options.netmask, :pool => options.pool if address then say_success "Address for #{options.tag} updated" else say_error "Address for #{options.tag} not updated" end end end