class MU::Cloud::Azure::VPC::Subnet
Subnets are almost a first-class resource. So let's kinda sorta treat them like one. This should only be invoked on objects that already exists in the cloud layer.
Attributes
az[R]
cloud_desc_cache[R]
cloud_id[R]
id[R]
ip_block[R]
mu_name[R]
name[R]
resource_group[R]
Public Class Methods
new(parent, config, precache_description: true)
click to toggle source
@param parent [MU::Cloud::Azure::VPC]: The parent VPC
of this subnet. @param config [Hash<String>]:
# File modules/mu/providers/azure/vpc.rb, line 734 def initialize(parent, config, precache_description: true) @parent = parent @deploy = parent.deploy @config = MU::Config.manxify(config) @cloud_id = config['cloud_id'] @mu_name = config['mu_name'] @name = config['name'] @deploydata = config # This is a dummy for the sake of describe() @ip_block = config['ip_block'] @cloud_desc_cache = nil @az = parent.config['region'] cloud_desc if precache_description end
Public Instance Methods
cloud_desc(use_cache: true)
click to toggle source
Describe this VPC
Subnet
from the cloud platform's perspective
# File modules/mu/providers/azure/vpc.rb, line 770 def cloud_desc(use_cache: true) return @cloud_desc_cache if @cloud_desc_cache and use_cache @cloud_desc_cache = MU::Cloud::Azure.network(credentials: @parent.credentials).subnets.get(@parent.resource_group, @parent.cloud_desc.name, @cloud_id.to_s) @cloud_desc_cache end
defaultRoute()
click to toggle source
Return the cloud identifier for the default route of this subnet.
# File modules/mu/providers/azure/vpc.rb, line 749 def defaultRoute if cloud_desc and cloud_desc.route_table rtb_id = MU::Cloud::Azure::Id.new(cloud_desc.route_table.id) routes = MU::Cloud::Azure.network(credentials: @config['credentials']).routes.list( rtb_id.resource_group, rtb_id.name ) routes.each { |route| return route if route.address_prefix == "0.0.0.0/0" } end nil end
notify()
click to toggle source
private?()
click to toggle source
Is this subnet privately-routable only, or public? @return [Boolean]
# File modules/mu/providers/azure/vpc.rb, line 778 def private? if cloud_desc and cloud_desc.route_table rtb_id = MU::Cloud::Azure::Id.new(cloud_desc.route_table.id) routes = MU::Cloud::Azure.network(credentials: @config['credentials']).routes.list( rtb_id.resource_group, rtb_id.name ) routes.each { |route| return false if route.next_hop_type == "Internet" } true end end