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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one

Constructor Details

#initialize(attributes = {}) ⇒ IpForwardingRule

Returns a new instance of IpForwardingRule.



22
23
24
# File 'lib/rackspace-fog/ninefold/models/compute/ip_forwarding_rule.rb', line 22

def initialize(attributes={})
  super
end

Instance Method Details

#addressObject



41
42
43
# File 'lib/rackspace-fog/ninefold/models/compute/ip_forwarding_rule.rb', line 41

def address
  Ninefold.address.get(ipaddressid)
end

#address=(addr) ⇒ Object



45
46
47
# File 'lib/rackspace-fog/ninefold/models/compute/ip_forwarding_rule.rb', line 45

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

#destroyObject



26
27
28
29
30
# File 'lib/rackspace-fog/ninefold/models/compute/ip_forwarding_rule.rb', line 26

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

#ready?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
# File 'lib/rackspace-fog/ninefold/models/compute/ip_forwarding_rule.rb', line 32

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

#saveObject



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

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 = connection.create_ip_forwarding_rule(options)
  merge_attributes(data)
  true
end