Class: Bosh::Director::DeploymentPlan::Network

Inherits:
Object
  • Object
show all
Includes:
Bosh::Director::DnsHelper, ValidationHelper
Defined in:
lib/bosh/director/deployment_plan/network.rb

Overview

Represents a logical deployment network.

Direct Known Subclasses

DynamicNetwork, ManualNetwork, VipNetwork

Constant Summary collapse

VALID_DEFAULTS =
%w(dns gateway).sort

Constants included from Bosh::Director::DnsHelper

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ValidationHelper

#invalid_type, #safe_property

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

Constructor Details

#initialize(deployment, network_spec) ⇒ Network

Creates a new network.

Parameters:

  • deployment (DeploymentPlan)

    associated deployment plan

  • network_spec (Hash)

    parsed deployment manifest network section



27
28
29
30
31
# File 'lib/bosh/director/deployment_plan/network.rb', line 27

def initialize(deployment, network_spec)
  @deployment = deployment
  @name = safe_property(network_spec, "name", :class => String)
  @canonical_name = canonical(@name)
end

Instance Attribute Details

#canonical_nameString

Returns canonical network name.

Returns:

  • (String)

    canonical network name



20
21
22
# File 'lib/bosh/director/deployment_plan/network.rb', line 20

def canonical_name
  @canonical_name
end

#deploymentDeploymentPlan

Returns associated deployment.

Returns:



14
15
16
# File 'lib/bosh/director/deployment_plan/network.rb', line 14

def deployment
  @deployment
end

#nameString

Returns network name.

Returns:

  • (String)

    network name



17
18
19
# File 'lib/bosh/director/deployment_plan/network.rb', line 17

def name
  @name
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

Raises:

  • (NotImplementedError)


68
69
70
71
# File 'lib/bosh/director/deployment_plan/network.rb', line 68

def network_settings(reservation, default_properties = VALID_DEFAULTS)
  raise NotImplementedError,
        "#network_settings not implemented for #{self.class}"
end

#release(reservation) ⇒ void

This method returns an undefined value.

Releases a previous reservation that had been fulfilled.

Parameters:

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/bosh/director/deployment_plan/network.rb', line 58

def release(reservation)
  raise NotImplementedError, "#release not implemented for #{self.class}"
end

#reserve(reservation) ⇒ Boolean

Reserves a network resource.

Will update the passed in reservation if it can be fulfilled.

Parameters:

Returns:

  • (Boolean)

    true if the reservation was fulfilled

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/bosh/director/deployment_plan/network.rb', line 50

def reserve(reservation)
  raise NotImplementedError, "#reserve not implemented for #{self.class}"
end

#reserve!(reservation, origin) ⇒ Object

Reserves a network resource, raises an error if reservation failed

Parameters:

  • reservation (NetworkReservation)

    Network reservation

  • origin (String)

    Whoever is reserving



37
38
39
40
41
42
# File 'lib/bosh/director/deployment_plan/network.rb', line 37

def reserve!(reservation, origin)
  reserve(reservation)
  unless reservation.reserved?
    reservation.handle_error(origin)
  end
end