Class: CpOraclecloud::ComputeInstance

Inherits:
CloudInstance
  • Object
show all
Includes:
ComputeMixin
Defined in:
app/models/cp_oraclecloud/compute_instance.rb

Instance Method Summary collapse

Methods included from ComputeMixin

#calculate_monthly_cost

Instance Method Details

#_provisionObject



5
6
7
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 5

def _provision
	connection.instances.create(init_config)
end

#attr_get(attribute) ⇒ Object



30
31
32
33
34
35
36
37
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 30

def attr_get(attribute)
	begin
		@instance ||= connection.instances.get(name)
		@instance.attributes[attribute.to_sym]
	rescue Fog::Compute::OracleCloud::NotFound
		"Error"
	end
end

#calc_cost(start_date, end_date) ⇒ Object



43
44
45
46
47
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 43

def calc_cost(start_date, end_date)
	cost = 0
	cost = (end_date - start_date) * (month_cost / 30)
	cost
end

#cloud_typeObject



17
18
19
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 17

def cloud_type
	"Compute"
end

#connectionObject



49
50
51
52
53
54
55
56
57
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 49

def connection 
    @connection ||= Fog::Compute.new(
      :provider => 'OracleCloud',
      :oracle_username => CpOraclecloud.username,
      :oracle_password => CpOraclecloud.password,
      :oracle_domain => CpOraclecloud.domain,
      :oracle_compute_api => CpOraclecloud.compute_api
      )
end

#fogObject



25
26
27
28
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 25

def fog
	@instance ||= connection.instances.get(name)
	@instance
end

#iconObject



21
22
23
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 21

def icon
	"fa-desktop"
end

#month_costObject



39
40
41
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 39

def month_cost
	calculate_monthly_cost(init_config)
end

#providerObject



13
14
15
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 13

def provider
	"OracleCloud"
end

#waitObject



9
10
11
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 9

def wait
	fog.wait_for { ready? }
end