Class: ZAWS::AWSCLI::Data::EC2::Subnet
- Inherits:
-
Object
- Object
- ZAWS::AWSCLI::Data::EC2::Subnet
show all
- Defined in:
- lib/zaws/external/awscli/data/ec2/subnet.rb
Instance Method Summary
collapse
Constructor Details
#initialize(shellout, ec2) ⇒ Subnet
Returns a new instance of Subnet.
7
8
9
10
11
|
# File 'lib/zaws/external/awscli/data/ec2/subnet.rb', line 7
def initialize(shellout, ec2)
@shellout=shellout
@ec2=ec2
@subnet_hash=nil
end
|
Instance Method Details
#available ⇒ Object
31
32
33
34
35
36
37
38
39
|
# 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) ⇒ Object
49
50
51
52
53
54
|
# 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) ⇒ Object
41
42
43
44
45
46
47
|
# 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) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# 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 ⇒ Object
13
14
15
|
# File 'lib/zaws/external/awscli/data/ec2/subnet.rb', line 13
def validJSON
return (@subnet_hash.nil?)
end
|
#view ⇒ Object
27
28
29
|
# File 'lib/zaws/external/awscli/data/ec2/subnet.rb', line 27
def view()
return @subnet_raw_data
end
|