Class: CpOraclecloud::ComputeInstance
- Inherits:
-
CloudInstance
- Object
- CloudInstance
- CpOraclecloud::ComputeInstance
- Includes:
- ComputeMixin
- Defined in:
- app/models/cp_oraclecloud/compute_instance.rb
Instance Method Summary collapse
- #_provision ⇒ Object
- #attr_get(attribute) ⇒ Object
- #calc_cost(start_date, end_date) ⇒ Object
- #cloud_type ⇒ Object
- #connection ⇒ Object
- #fog ⇒ Object
- #icon ⇒ Object
- #month_cost ⇒ Object
- #provider ⇒ Object
- #wait ⇒ Object
Methods included from ComputeMixin
Instance Method Details
#_provision ⇒ Object
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_type ⇒ Object
17 18 19 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 17 def cloud_type "Compute" end |
#connection ⇒ Object
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 |
#fog ⇒ Object
25 26 27 28 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 25 def fog @instance ||= connection.instances.get(name) @instance end |
#icon ⇒ Object
21 22 23 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 21 def icon "fa-desktop" end |
#month_cost ⇒ Object
39 40 41 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 39 def month_cost calculate_monthly_cost(init_config) end |
#provider ⇒ Object
13 14 15 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 13 def provider "OracleCloud" end |
#wait ⇒ Object
9 10 11 |
# File 'app/models/cp_oraclecloud/compute_instance.rb', line 9 def wait fog.wait_for { ready? } end |