Class: Fog::Compute::Packet::Device
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Packet::Device
- Defined in:
- lib/fog/compute/packet/models/device.rb
Overview
Device Model
Instance Method Summary collapse
- #destroy ⇒ Object
- #inactive? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Device
constructor
A new instance of Device.
- #ready? ⇒ Boolean
- #reboot ⇒ Object
- #reload ⇒ Object
- #save ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Device
Returns a new instance of Device.
44 45 46 |
# File 'lib/fog/compute/packet/models/device.rb', line 44 def initialize(attributes = {}) super end |
Instance Method Details
#destroy ⇒ Object
112 113 114 115 116 117 |
# File 'lib/fog/compute/packet/models/device.rb', line 112 def destroy requires :id response = service.delete_device(id) true if response.status == 204 end |
#inactive? ⇒ Boolean
130 131 132 |
# File 'lib/fog/compute/packet/models/device.rb', line 130 def inactive? state == "inactive" end |
#ready? ⇒ Boolean
126 127 128 |
# File 'lib/fog/compute/packet/models/device.rb', line 126 def ready? state == "active" end |
#reboot ⇒ Object
94 95 96 97 98 |
# File 'lib/fog/compute/packet/models/device.rb', line 94 def reboot requires :id response = service.reboot_device(id) true if response.status == 202 end |
#reload ⇒ Object
119 120 121 122 123 124 |
# File 'lib/fog/compute/packet/models/device.rb', line 119 def reload requires :id response = service.get_device(id) return unless response.body merge_attributes(response.body) end |
#save ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/compute/packet/models/device.rb', line 48 def save requires :project_id, :facility, :plan, :hostname, :operating_system = {} [:plan] = plan [:facility] = facility [:hostname] = hostname [:operating_system] = [:description] = description if description [:billing_cycle] = billing_cycle if billing_cycle [:always_pxe] = always_pxe if always_pxe [:ipxe_script_url] = ipxe_script_url if ipxe_script_url [:userdata] = userdata if userdata [:locked] = locked if locked [:hardware_reservation_id] = hardware_reservation_id if hardware_reservation_id [:spot_instance] = spot_instance if spot_instance [:spot_price_max] = spot_price_max if spot_price_max [:termination_time] = termination_time if termination_time [:tags] = if [:project_ssh_keys] = project_ssh_keys if project_ssh_keys [:user_ssh_keys] = user_ssh_keys if user_ssh_keys [:features] = features if features response = service.create_device(project_id, ) merge_attributes(response.body) end |
#start ⇒ Object
100 101 102 103 104 |
# File 'lib/fog/compute/packet/models/device.rb', line 100 def start requires :id response = service.poweron_device(id) true if response.status == 202 end |
#stop ⇒ Object
106 107 108 109 110 |
# File 'lib/fog/compute/packet/models/device.rb', line 106 def stop requires :id response = service.poweroff_device(id) true if response.status == 202 end |
#update ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fog/compute/packet/models/device.rb', line 76 def update requires :id = {} [:hostname] = hostname if hostname [:description] = description if description [:billing_cycle] = billing_cycle if billing_cycle [:userdata] = userdata if userdata [:locked] = locked if locked [:tags] = if [:always_pxe] = always_pxe if always_pxe [:ipxe_script_url] = ipxe_script_url if ipxe_script_url [:spot_instance] = spot_instance if spot_instance response = service.update_device(id, ) merge_attributes(response.body) end |