Class: Bosh::Director::DeploymentPlan::DynamicNetwork

Inherits:
Network show all
Includes:
Bosh::Director::DnsHelper
Defined in:
lib/bosh/director/deployment_plan/dynamic_network.rb

Constant Summary collapse

DYNAMIC_IP =
NetAddr::CIDR.create("255.255.255.255").to_i

Constants included from Bosh::Director::DnsHelper

Bosh::Director::DnsHelper::SOA, Bosh::Director::DnsHelper::TTL_4H, Bosh::Director::DnsHelper::TTL_5M

Constants inherited from Network

Network::VALID_DEFAULTS

Instance Attribute Summary collapse

Attributes inherited from Network

#canonical_name, #deployment, #name

Instance Method Summary collapse

Methods included from Bosh::Director::DnsHelper

#add_default_dns_server, #canonical, #default_dns_server, #delete_dns_records, #delete_empty_domain, #dns_domain_name, #dns_ns_record, #dns_servers, #flush_dns_cache, #invalid_dns, #reverse_domain, #reverse_host, #update_dns_a_record, #update_dns_ptr_record

Methods inherited from Network

#reserve!

Methods included from ValidationHelper

#invalid_type, #safe_property

Constructor Details

#initialize(deployment, network_spec) ⇒ DynamicNetwork

Creates a new network.

Parameters:

  • deployment (DeploymentPlan)

    associated deployment plan

  • network_spec (Hash)

    parsed deployment manifest network section



23
24
25
26
27
28
29
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 23

def initialize(deployment, network_spec)
  super
  @cloud_properties =
    safe_property(network_spec, "cloud_properties", class: Hash, default: {})

  @dns = dns_servers(network_spec["name"], network_spec)
end

Instance Attribute Details

#cloud_propertiesHash

Returns Network cloud properties.

Returns:

  • (Hash)

    Network cloud properties



12
13
14
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 12

def cloud_properties
  @cloud_properties
end

#dnsArray

Returns an array of DNS servers.

Returns:

  • (Array)

    an array of DNS servers



16
17
18
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 16

def dns
  @dns
end

Instance Method Details

#network_settings(reservation, default_properties = VALID_DEFAULTS) ⇒ Hash

Returns the network settings for the specific reservation.

Parameters:

Returns:

  • (Hash)

    network settings that will be passed to the BOSH Agent



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 64

def network_settings(reservation, default_properties = VALID_DEFAULTS)
  validate_ip(reservation)

  config = {
    "type" => "dynamic",
    "cloud_properties" => @cloud_properties
  }
  config["dns"] = @dns if @dns

  if default_properties
    config["default"] = default_properties.sort
  end

  config
end

#release(reservation) ⇒ void

This method returns an undefined value.

Releases a previous reservation that had been fulfilled.

Parameters:



54
55
56
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 54

def release(reservation)
  validate_ip(reservation)
end

#reserve(reservation) ⇒ Boolean

Reserves a network resource.

This is either an already used reservation being verified or a new one waiting to be fulfilled.

Parameters:

Returns:

  • (Boolean)

    true if the reservation was fulfilled



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bosh/director/deployment_plan/dynamic_network.rb', line 38

def reserve(reservation)
  reservation.reserved = false
  if reservation.static?
    reservation.error = NetworkReservation::WRONG_TYPE
  else
    reservation.ip = DYNAMIC_IP
    reservation.reserved = true
    reservation.type = NetworkReservation::DYNAMIC
  end
  reservation.reserved?
end