class ZAWS::AWSCLI::Data::EC2::Subnet

Public Class Methods

new(shellout, ec2) click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 7
def initialize(shellout, ec2)
  @shellout=shellout
  @ec2=ec2
  @subnet_hash=nil
end

Public Instance Methods

available() click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 31
def available()
  if @subnet_hash and @subnet_hash["Subnet"]
    return (@subnet_hash["Subnet"]["State"] == "available")
  end
  if @subnet_hash and @subnet_hash["Subnets"] and @subnet_hash["Subnets"].count == 1
    return (@subnet_hash["Subnets"][0]["State"] == "available")
  end
  return false
end
id_by_cidrblock(verbose=nil) click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 49
def id_by_cidrblock(verbose=nil)
  return nil if not @subnet_hash["Subnets"]
  subnet_id= @subnet_hash["Subnets"].count == 1 ? @subnet_hash["Subnets"][0]["SubnetId"] : nil
  verbose.puts subnet_id if verbose
  return subnet_id
end
id_by_ip(ip,verbose=nil) click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 41
def id_by_ip(ip,verbose=nil)
  return nil if not @subnet_hash["Subnets"]
  subnet_id=nil
  @subnet_hash["Subnets"].each { |x| subnet_id = x["SubnetId"] if (NetAddr::CIDR.create(x["CidrBlock"])).contains?(ip) }
  verbose.puts subnet_id if verbose
  return subnet_id
end
load(command, data,verbose) click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 17
def load(command, data,verbose)
  @subnet_raw_data = data
  verbose.puts(@subnet_raw_data) if verbose
  @subnet_hash=nil
  begin
    @subnet_hash =JSON.parse(data)
  rescue JSON::ParserError => e
  end
end
validJSON() click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 13
def validJSON
  return (@subnet_hash.nil?)
end
view() click to toggle source
# File lib/zaws/external/awscli/data/ec2/subnet.rb, line 27
def view()
  return @subnet_raw_data
end