Class: QC::Eip

Inherits:
DataType show all
Defined in:
lib/qc.rb

Instance Attribute Summary

Attributes inherited from DataType

#result

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DataType

describe, #initialize, #method_missing, #to_s

Constructor Details

This class inherits a constructor from QC::DataType

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class QC::DataType

Class Method Details

.allocate(p = {bandwidth: 1, eip_name: nil, count: 1, need_icp: nil, zone: nil}) ⇒ Object



136
137
138
139
140
141
142
143
# File 'lib/qc.rb', line 136

def Eip.allocate p = {bandwidth: 1, eip_name: nil, count: 1, need_icp: nil, zone: nil}
  ret = API::Request.execute! 'AllocateEips', p
  if ret.respond_to? :has_key?
    ret['eips']
  else
    false
  end
end

.load(eip_id) ⇒ Object



156
157
158
# File 'lib/qc.rb', line 156

def Eip.load eip_id
  Eip.describe('eips.1' => eip_id)[0]
end

.release(eips: [], zone: nil) ⇒ Object



145
146
147
148
149
150
151
152
153
154
# File 'lib/qc.rb', line 145

def Eip.release eips: [], zone: nil
  if eips.size > 0
    p = {}
    1.upto(eips.size).each { |i| p["eips.#{i}"] = eips[i-1] }
    p[:zone] = zone
    API::Request.execute!('ReleaseEips', p)
  else
    false
  end
end

Instance Method Details

#bandwidth=(b) ⇒ Object



160
161
162
163
164
165
166
167
168
# File 'lib/qc.rb', line 160

def bandwidth= b
  p = {'eips.1' => @values['eip_id'], 'bandwidth' => b}
  ret = API::Request.execute!('ChangeEipsBandwidth', p)
  if ret.respond_to? :has_key?
    b
  else
    false
  end
end

#release!Object



170
171
172
173
# File 'lib/qc.rb', line 170

def release!
  p = {'eips.1' => @values['eip_id']}
  API::Request.execute!('ReleaseEips', p)
end