Class: Saklient::Cloud::Resources::Server
- Inherits:
-
Resource
- Object
- Resource
- Saklient::Cloud::Resources::Server
- Defined in:
- lib/saklient/cloud/resources/server.rb
Overview
サーバの実体1つに対応し, 属性の取得や操作を行うためのクラス.
Instance Attribute Summary (collapse)
-
- (ServerActivity) activity
readonly
アクティビティ.
-
- (String) availability
readonly
有効状態 Enums::EAvailability.
-
- (String) description
説明.
-
- (Icon) icon
アイコン.
-
- (String) id
readonly
ID.
-
- (Array<Iface>) ifaces
readonly
インタフェース.
-
- (ServerInstance) instance
readonly
インスタンス情報.
-
- (String) name
名前.
-
- (ServerPlan) plan
プラン.
-
- (Array<String>) tags
タグ文字列の配列.
Instance Method Summary (collapse)
-
- (Iface) add_iface
サーバにインタフェースを1つ増設し, それを取得します.
-
- (Server) boot
サーバを起動します.
-
- (Server) change_plan(planTo)
サーバプランを変更します.
-
- (Server) eject_iso_image
サーバに挿入されているISOイメージを排出します.
-
- (Array<Disk>) find_disks
サーバに接続されているディスクのリストを取得します.
-
- (Server) insert_iso_image(iso)
サーバにISOイメージを挿入します.
-
- (bool) is_down
サーバが停止しているときtrueを返します.
-
- (bool) is_up
サーバが起動しているときtrueを返します.
-
- (Server) reboot
サーバを強制再起動します.
-
- (Server) reload
最新のリソース情報を再取得します.
-
- (Server) save
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
-
- (Server) shutdown
サーバをシャットダウンします.
-
- (bool) sleep_until_down(timeoutSec = 180)
サーバが停止するまで待機します.
-
- (bool) sleep_until_up(timeoutSec = 180)
サーバが起動するまで待機します.
-
- (Server) stop
サーバを強制停止します.
Instance Attribute Details
- (ServerActivity) activity (readonly)
アクティビティ
138 139 140 |
# File 'lib/saklient/cloud/resources/server.rb', line 138 def activity @activity end |
- (String) availability (readonly)
有効状態 Enums::EAvailability
610 611 612 |
# File 'lib/saklient/cloud/resources/server.rb', line 610 def availability @availability end |
- (String) description
説明
412 413 414 |
# File 'lib/saklient/cloud/resources/server.rb', line 412 def description @description end |
- (Icon) icon
アイコン
493 494 495 |
# File 'lib/saklient/cloud/resources/server.rb', line 493 def icon @icon end |
- (String) id (readonly)
ID
336 337 338 |
# File 'lib/saklient/cloud/resources/server.rb', line 336 def id @id end |
- (Array<Iface>) ifaces (readonly)
インタフェース
562 563 564 |
# File 'lib/saklient/cloud/resources/server.rb', line 562 def ifaces @ifaces end |
- (ServerInstance) instance (readonly)
インスタンス情報
586 587 588 |
# File 'lib/saklient/cloud/resources/server.rb', line 586 def instance @instance end |
- (String) name
名前
372 373 374 |
# File 'lib/saklient/cloud/resources/server.rb', line 372 def name @name end |
- (ServerPlan) plan
プラン
534 535 536 |
# File 'lib/saklient/cloud/resources/server.rb', line 534 def plan @plan end |
- (Array<String>) tags
タグ文字列の配列
453 454 455 |
# File 'lib/saklient/cloud/resources/server.rb', line 453 def @tags end |
Instance Method Details
- (Iface) add_iface
サーバにインタフェースを1つ増設し, それを取得します.
288 289 290 291 292 293 |
# File 'lib/saklient/cloud/resources/server.rb', line 288 def add_iface model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Iface', [@_client]) res = model.create res.server_id = _id return res.save end |
- (Server) boot
サーバを起動します.
185 186 187 188 |
# File 'lib/saklient/cloud/resources/server.rb', line 185 def boot @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power') return reload end |
- (Server) change_plan(planTo)
サーバプランを変更します.
成功時はリソースIDが変わることにご注意ください.
269 270 271 272 273 274 275 |
# File 'lib/saklient/cloud/resources/server.rb', line 269 def change_plan(planTo) Saklient::Util::validate_type(planTo, 'Saklient::Cloud::Resources::ServerPlan') path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/to/plan/' + Saklient::Util::url_encode(planTo._id) result = @_client.request('PUT', path) api_deserialize(result, true) return self end |
- (Server) eject_iso_image
サーバに挿入されているISOイメージを排出します.
311 312 313 314 315 316 |
# File 'lib/saklient/cloud/resources/server.rb', line 311 def eject_iso_image path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/cdrom' @_client.request('DELETE', path) reload return self end |
- (Array<Disk>) find_disks
サーバに接続されているディスクのリストを取得します.
280 281 282 283 |
# File 'lib/saklient/cloud/resources/server.rb', line 280 def find_disks model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Disk', [@_client]) return model.with_server_id(_id).find end |
- (Server) insert_iso_image(iso)
サーバにISOイメージを挿入します.
299 300 301 302 303 304 305 306 |
# File 'lib/saklient/cloud/resources/server.rb', line 299 def insert_iso_image(iso) Saklient::Util::validate_type(iso, 'Saklient::Cloud::Resources::IsoImage') path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/cdrom' q = { CDROM: { ID: iso._id } } @_client.request('PUT', path, q) reload return self end |
- (bool) is_down
サーバが停止しているときtrueを返します.
178 179 180 |
# File 'lib/saklient/cloud/resources/server.rb', line 178 def is_down return get_instance.is_down end |
- (bool) is_up
サーバが起動しているときtrueを返します.
171 172 173 |
# File 'lib/saklient/cloud/resources/server.rb', line 171 def is_up return get_instance.is_up end |
- (Server) reboot
サーバを強制再起動します.
209 210 211 212 |
# File 'lib/saklient/cloud/resources/server.rb', line 209 def reboot @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/reset') return reload end |
- (Server) reload
最新のリソース情報を再取得します.
117 118 119 |
# File 'lib/saklient/cloud/resources/server.rb', line 117 def reload return _reload end |
- (Server) save
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
110 111 112 |
# File 'lib/saklient/cloud/resources/server.rb', line 110 def save return _save end |
- (Server) shutdown
サーバをシャットダウンします.
193 194 195 196 |
# File 'lib/saklient/cloud/resources/server.rb', line 193 def shutdown @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power') return reload end |
- (bool) sleep_until_down(timeoutSec = 180)
サーバが停止するまで待機します.
227 228 229 230 |
# File 'lib/saklient/cloud/resources/server.rb', line 227 def sleep_until_down(timeoutSec = 180) Saklient::Util::validate_type(timeoutSec, 'Fixnum') return sleep_until(Saklient::Cloud::Enums::EServerInstanceStatus::down, timeoutSec) end |
- (bool) sleep_until_up(timeoutSec = 180)
サーバが起動するまで待機します.
218 219 220 221 |
# File 'lib/saklient/cloud/resources/server.rb', line 218 def sleep_until_up(timeoutSec = 180) Saklient::Util::validate_type(timeoutSec, 'Fixnum') return sleep_until(Saklient::Cloud::Enums::EServerInstanceStatus::up, timeoutSec) end |
- (Server) stop
サーバを強制停止します.
201 202 203 204 |
# File 'lib/saklient/cloud/resources/server.rb', line 201 def stop @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power', { Force: true }) return reload end |