Class: Fog::Compute::OracleCloud::IpReservation

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

Instance Method Summary collapse

Instance Method Details

#createObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/oraclecloud/models/compute/ip_reservation.rb', line 29

def create 
  requires :name
  data = service.create_ip_reservation({
  	:name => name,
  	:parentpool => parentpool || '/oracle/public/ippool', 
  	:permanent => permanent || true,
  	:tags => tags
  })
  merge_attributes(data.body)
end

#destroyObject



51
52
53
54
# File 'lib/fog/oraclecloud/models/compute/ip_reservation.rb', line 51

def destroy
	requires :name
	service.delete_ip_reservation(name)
end

#saveObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/oraclecloud/models/compute/ip_reservation.rb', line 18

def save
  begin
    # Check if it's already created
    res = Fog::Compute[:oraclecloud].ip_reservations.get(name)
    update
  rescue Fog::Compute::OracleCloud::NotFound    
    # It wasn't found. 
    create
  end
end

#updateObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/oraclecloud/models/compute/ip_reservation.rb', line 40

def update
  requires :name, :parentpool
	data = service.update_ip_reservation({
		:name => name,
		:parentpool => parentpool,
		:permanent => permanent,
		:tags => tags
	})
	merge_attributes(data.body)
end