Class: Fog::Compute::Ninefold::IpForwardingRule

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/ninefold/models/compute/ip_forwarding_rule.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ IpForwardingRule

Returns a new instance of IpForwardingRule.



20
21
22
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 20

def initialize(attributes={})
  super
end

Instance Method Details

#addressObject



39
40
41
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 39

def address
  Ninefold.address.get(ipaddressid)
end

#address=(addr) ⇒ Object



43
44
45
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 43

def address=(addr)
  self.ipaddressid = addr.identity
end

#destroyObject



24
25
26
27
28
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 24

def destroy
  requires :identity
  self.jobid = extract_job_id(service.delete_ip_forwarding_rule(:id => identity))
  true
end

#ready?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 30

def ready?
  if jobid && service.query_async_job_result(:jobid => jobid)['jobstatus'] == 0
    false
  else # No running job, we are ready. Refresh data.
    reload
    true
  end
end

#saveObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/ninefold/models/compute/ip_forwarding_rule.rb', line 47

def save
  raise "Operation not supported" if self.identity
  requires :ipaddressid
  requires :protocol
  requires :startport

  options = {
    :ipaddressid => ipaddressid,
    :protocol => protocol,
    :startport => startport,
    :endport => endport
  }.delete_if {|k,v| v.nil? || v == "" }
  data = service.create_ip_forwarding_rule(options)
  merge_attributes(data)
  true
end