class Saklient::Cloud::Resources::Server

サーバの実体1つに対応し, 属性の取得や操作を行うためのクラス.

Attributes

_activity[RW]

@private @return [ServerActivity]

activity[R]

アクティビティ

@return [ServerActivity]

availability[R]

有効状態 {Saklient::Cloud::Enums::EAvailability}

@return [String]

description[RW]

説明

@return [String]

host_name[RW]

ホスト名

@return [String]

icon[RW]

アイコン

@return [Icon]

id[R]

ID

@return [String]

ifaces[R]

インタフェース

@return [Array<Iface>]

instance[R]

インスタンス情報

@return [ServerInstance]

m_availability[RW]

有効状態 {Saklient::Cloud::Enums::EAvailability}

@return [String]

m_description[RW]

説明

@return [String]

m_host_name[RW]

ホスト名

@return [String]

m_icon[RW]

アイコン

@return [Icon]

m_id[RW]

ID

@return [String]

m_ifaces[RW]

インタフェース

@return [Array<Iface>]

m_instance[RW]

インスタンス情報

@return [ServerInstance]

m_name[RW]

名前

@return [String]

m_plan[RW]

プラン

@return [ServerPlan]

m_tags[RW]

タグ文字列の配列

@return [Array<String>]

n_availability[RW]

@return [bool]

n_description[RW]

@return [bool]

n_host_name[RW]

@return [bool]

n_icon[RW]

@return [bool]

n_id[RW]

@return [bool]

n_ifaces[RW]

@return [bool]

n_instance[RW]

@return [bool]

n_name[RW]

@return [bool]

n_plan[RW]

@return [bool]

n_tags[RW]

@return [bool]

name[RW]

名前

@return [String]

plan[RW]

プラン

@return [ServerPlan]

tags[RW]

タグ文字列の配列

@return [Array<String>]

Public Class Methods

new(client, obj, wrapped = false) click to toggle source

@private @param [Saklient::Cloud::Client] client @param [any] obj @param [bool] wrapped

# File lib/saklient/cloud/resources/server.rb, line 157
def initialize(client, obj, wrapped = false)
  super(client)
  Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
  Saklient::Util::validate_type(wrapped, 'bool')
  @_activity = Saklient::Cloud::Resources::ServerActivity.new(client)
  api_deserialize(obj, wrapped)
end

Public Instance Methods

_class_name() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 106
def _class_name
  return 'Server'
end
_id() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 112
def _id
  return get_id
end
add_iface() click to toggle source

サーバにインタフェースを1つ増設し, それを取得します.

@return [Iface] 増設されたインタフェース

# File lib/saklient/cloud/resources/server.rb, line 469
def add_iface
  model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Iface', [@_client])
  res = model.create
  res.server_id = _id
  res.save
  reload
  return res
end
boot() click to toggle source

サーバを起動します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 366
def boot
  @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
  return reload
end
change_plan(planTo) click to toggle source

サーバプランを変更します.

成功時はリソースIDが変わることにご注意ください.

@param [ServerPlan] planTo @return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 450
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
description=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 630
def description=(v)
  set_description(v)
end
easy_duplicate(userIpAddress = nil, diskSource = nil, sshKey = nil, hostName = nil, name = nil) click to toggle source

サーバ および そのサーバに接続されている1台目のディスクを複製し, 同一ネットワークに接続します. ディスクのコピー中は待機し, 完了してからreturnします.

   共有セグメントに接続されている場合はAPIによって自動的に割り当てられるため, 省略またはnullを指定してください.
   文字列 "skip" を指定すると, ディスク修正処理をスキップします.
trueを指定した場合は, 複製元の現在のディスク#1から直接クローンします.
省略またはnullを指定した場合は, 複製元のディスク#1が作成された時のコピー元リソースから再度クローンを試みます.
既に削除されている場合は, 複製元の現在のディスク#1からの直接クローンにフォールバックします.
いずれの場合も, 作成されるディスクのプランとサイズは複製元のサーバの1台目のディスクと同一のものが選択されます.
作成されるディスクは1台目だけで, 2台目以降は無視されます.

@param [String] userIpAddress 最初のインタフェースに割り当てるIPアドレスを指定します. @param [any] diskSource ディスク#1のクローン元リソース(DiskまたはArchive)を指定します. 見つからないときは例外が発生します. @param hostname 新しいサーバのホスト名(自動的にホスト名をつける場合は省略またはnullを指定) @param [String] name 新しいサーバの名前(自動的に名前をつける場合は省略またはnullを指定) @param [String] sshKey @param [String] hostName @return [Server]

# File lib/saklient/cloud/resources/server.rb, line 183
def easy_duplicate(userIpAddress = nil, diskSource = nil, sshKey = nil, hostName = nil, name = nil)
  Saklient::Util::validate_type(userIpAddress, 'String')
  Saklient::Util::validate_type(sshKey, 'String')
  Saklient::Util::validate_type(hostName, 'String')
  Saklient::Util::validate_type(name, 'String')
  server = Saklient::Cloud::Resources::Server.new(@_client, nil)
  names = []
  hostNames = []
  skipConfig = userIpAddress == 'skip'
  userIpAddress = nil if skipConfig
  if (name).nil? || (hostName).nil?
    model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Server', [@_client])
    servers = model.limit(0).find
    s = nil
    for s in servers
      names << s.get_name
      hostNames << s.get_host_name
    end
  end
  name = Saklient::Util::auto_rename(self.name, names) if (name).nil?
  hostName = Saklient::Util::auto_rename(self.host_name, hostNames) if (hostName).nil?
  server.set_name(name)
  server.set_host_name(hostName)
  server.set_description(self.description)
  server.set_tags(self.tags)
  server.set_icon(self.icon)
  server.set_plan(self.plan)
  iface = nil
  if 0 < self.ifaces.length
    iface = self.ifaces[0]
    iface.reload
    if !(userIpAddress).nil?
      if (iface.ip_address).nil?
        raise Saklient::Errors::SaklientException.new('invalid_data', 'Setting an IP address to the disconnected interface is not allowed') if (iface.swytch_id).nil?
      else
        raise Saklient::Errors::SaklientException.new('invalid_data', 'Setting an IP address to the interface connected to a shared segment is not allowed')
      end
    end
  end
  srcDisks = find_disks
  if 0 < srcDisks.length
    if Saklient::Util::are_same(diskSource, true)
      diskSource = srcDisks[0]
    else
      if (diskSource).nil?
        diskSource = srcDisks[0].source
        if (diskSource).nil?
          diskSource = srcDisks[0]
        else
          if diskSource.is_a?(Saklient::Cloud::Resources::Archive)
            begin
              diskSource.reload
            rescue Saklient::Errors::HttpNotFoundException
              diskSource = srcDisks[0]
            end
          else
            if diskSource.is_a?(Saklient::Cloud::Resources::Disk)
              begin
                diskSource.reload
              rescue Saklient::Errors::HttpNotFoundException
                diskSource = srcDisks[0]
              end
            end
          end
        end
      end
    end
    if diskSource.is_a?(Saklient::Cloud::Resources::Archive)
      diskSource.reload
    else
      diskSource.reload if diskSource.is_a?(Saklient::Cloud::Resources::Disk)
    end
  end
  server.save
  disk = nil
  if !(diskSource).nil? && diskSource.is_a?(Saklient::Cloud::Resources::Resource)
    disk = Saklient::Cloud::Resources::Disk.new(@_client, nil)
    disk.source = diskSource
    disk.name = (name).nil? ? srcDisks[0].name : name
    disk.description = srcDisks[0].description
    disk.tags = srcDisks[0].tags
    disk.icon = srcDisks[0].icon
    disk.plan = srcDisks[0].plan
    disk.size_mib = srcDisks[0].size_mib
    disk.server = server
    disk.save
  end
  iface1st = nil
  userSwytch = nil
  for iface in self.ifaces
    iface.reload
    newIface = server.add_iface
    if (iface1st).nil?
      if !(iface.ip_address).nil?
        newIface.connect_to_shared_segment
      else
        newIface.connect_to_swytch_by_id(iface.swytch_id) if !(iface.swytch_id).nil?
        if !(userIpAddress).nil?
          newIface.user_ip_address = userIpAddress
          newIface.save
        end
        userSwytch = iface.find_swytch
        iface1st = iface
      end
    else
      newIface.connect_to_swytch_by_id(iface.swytch_id) if !(iface.swytch_id).nil?
    end
  end
  if !(disk).nil?
    disk.sleep_while_copying
    if !skipConfig
      diskconf = disk.create_config
      diskconf.host_name = hostName
      diskconf.ssh_key = sshKey
      diskconf.ip_address = userIpAddress
      if !(userSwytch).nil?
        if 0 < userSwytch.ipv4_nets.length
          net = userSwytch.ipv4_nets[0]
          diskconf.default_route = net.default_route
          diskconf.network_mask_len = net.mask_len
        else
          diskconf.default_route = userSwytch.user_default_route
          diskconf.network_mask_len = userSwytch.user_mask_len
        end
      end
      diskconf.write
    end
  end
  server.reload
  return server
end
eject_iso_image() click to toggle source

サーバに挿入されているISOイメージを排出します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 494
def eject_iso_image
  path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/cdrom'
  @_client.request('DELETE', path)
  reload
  return self
end
find_disks() click to toggle source

サーバに接続されているディスクのリストを取得します.

@return [Array<Disk>]

# File lib/saklient/cloud/resources/server.rb, line 461
def find_disks
  model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Disk', [@_client])
  return model.with_server_id(_id).sort_by_connection_order.find
end
get_activity() click to toggle source

@private @return [ServerActivity]

# File lib/saklient/cloud/resources/server.rb, line 140
def get_activity
  return @_activity
end
host_name=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 840
def host_name=(v)
  set_host_name(v)
end
icon=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 711
def icon=(v)
  set_icon(v)
end
insert_iso_image(iso) click to toggle source

サーバにISOイメージを挿入します.

@param [IsoImage] iso @return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 482
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
is_down() click to toggle source

サーバが停止しているときtrueを返します.

@return [bool]

# File lib/saklient/cloud/resources/server.rb, line 359
def is_down
  return get_instance.is_down
end
is_up() click to toggle source

サーバが起動しているときtrueを返します.

@return [bool]

# File lib/saklient/cloud/resources/server.rb, line 352
def is_up
  return get_instance.is_up
end
name=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 590
def name=(v)
  set_name(v)
end
plan=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 752
def plan=(v)
  set_plan(v)
end
reboot() click to toggle source

サーバを強制再起動します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 390
def reboot
  @_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/reset')
  return reload
end
reload() click to toggle source

最新のリソース情報を再取得します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 126
def reload
  return _reload
end
save() click to toggle source

このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 119
def save
  return _save
end
shutdown() click to toggle source

サーバをシャットダウンします.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 374
def shutdown
  @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
  return reload
end
sleep_until_down(timeoutSec = 180) click to toggle source

サーバが停止するまで待機します.

@param [Fixnum] timeoutSec @return [bool] 成功時はtrue, タイムアウトやエラーによる失敗時はfalseを返します.

# File lib/saklient/cloud/resources/server.rb, line 408
def sleep_until_down(timeoutSec = 180)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  return sleep_until(Saklient::Cloud::Enums::EServerInstanceStatus::down, timeoutSec)
end
sleep_until_up(timeoutSec = 180) click to toggle source

サーバが起動するまで待機します.

@param [Fixnum] timeoutSec @return [bool]

# File lib/saklient/cloud/resources/server.rb, line 399
def sleep_until_up(timeoutSec = 180)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  return sleep_until(Saklient::Cloud::Enums::EServerInstanceStatus::up, timeoutSec)
end
sleep_while_copying(timeoutSec = 3600) click to toggle source

サーバに接続されているコピー中のディスクが利用可能になるまで待機します.

@param [Fixnum] timeoutSec @return [bool] 成功時はtrue, タイムアウトやエラーによる失敗時はfalseを返します.

# File lib/saklient/cloud/resources/server.rb, line 505
def sleep_while_copying(timeoutSec = 3600)
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  step = 10
  disks = find_disks
  while 0 < timeoutSec do
    disk = nil
    begin
      reload
      for disk in disks
        disk.reload
      end
    rescue Saklient::Errors::HttpException
      {}
    end
    result = get_availability == Saklient::Cloud::Enums::EAvailability::available
    for disk in disks
      result = false if disk.availability != Saklient::Cloud::Enums::EAvailability::available
    end
    return true if result
    timeoutSec -= step
    sleep(step) if 0 < timeoutSec
  end
  return false
end
stop() click to toggle source

サーバを強制停止します.

@return [Server] this

# File lib/saklient/cloud/resources/server.rb, line 382
def stop
  @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power', { Force: true })
  return reload
end
tags=(v) click to toggle source
# File lib/saklient/cloud/resources/server.rb, line 671
def tags=(v)
  set_tags(v)
end

Protected Instance Methods

_api_path() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 86
def _api_path
  return '/server'
end
_on_after_api_deserialize(r, root) click to toggle source

@private @param [any] r @param [any] root @return [void]

# File lib/saklient/cloud/resources/server.rb, line 343
def _on_after_api_deserialize(r, root)
  @_activity.set_source_id(_id) if !(r).nil?
end
_on_before_api_deserialize(r, root) click to toggle source

@private @param [any] r @param [any] root @return [void]

# File lib/saklient/cloud/resources/server.rb, line 321
def _on_before_api_deserialize(r, root)
  return nil if (r).nil?
  id = r[:ID]
  ifaces = Saklient::Util::get_by_path(r, 'Interfaces')
  if !(ifaces).nil?
    for iface in ifaces
      server = nil
      if !iface.nil? && iface.key?(:Server)
        server = iface[:Server]
      else
        server = {}
        iface[:Server] = server
      end
      server[:ID] = id
    end
  end
end
_root_key() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 92
def _root_key
  return 'Server'
end
_root_key_m() click to toggle source

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 98
def _root_key_m
  return 'Servers'
end
api_deserialize_impl(r) click to toggle source

(This method is generated in Translator_default#buildImpl)

@param [any] r

# File lib/saklient/cloud/resources/server.rb, line 873
def api_deserialize_impl(r)
  @is_new = (r).nil?
  r = {} if @is_new
  @is_incomplete = false
  if Saklient::Util::exists_path(r, 'ID')
    @m_id = (Saklient::Util::get_by_path(r, 'ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'ID').to_s
  else
    @m_id = nil
    @is_incomplete = true
  end
  @n_id = false
  if Saklient::Util::exists_path(r, 'Name')
    @m_name = (Saklient::Util::get_by_path(r, 'Name')).nil? ? nil : Saklient::Util::get_by_path(r, 'Name').to_s
  else
    @m_name = nil
    @is_incomplete = true
  end
  @n_name = false
  if Saklient::Util::exists_path(r, 'Description')
    @m_description = (Saklient::Util::get_by_path(r, 'Description')).nil? ? nil : Saklient::Util::get_by_path(r, 'Description').to_s
  else
    @m_description = nil
    @is_incomplete = true
  end
  @n_description = false
  if Saklient::Util::exists_path(r, 'Tags')
    if (Saklient::Util::get_by_path(r, 'Tags')).nil?
      @m_tags = []
    else
      @m_tags = []
      for t in Saklient::Util::get_by_path(r, 'Tags')
        v1 = nil
        v1 = (t).nil? ? nil : t.to_s
        @m_tags << v1
      end
    end
  else
    @m_tags = nil
    @is_incomplete = true
  end
  @n_tags = false
  if Saklient::Util::exists_path(r, 'Icon')
    @m_icon = (Saklient::Util::get_by_path(r, 'Icon')).nil? ? nil : Saklient::Cloud::Resources::Icon.new(@_client, Saklient::Util::get_by_path(r, 'Icon'))
  else
    @m_icon = nil
    @is_incomplete = true
  end
  @n_icon = false
  if Saklient::Util::exists_path(r, 'ServerPlan')
    @m_plan = (Saklient::Util::get_by_path(r, 'ServerPlan')).nil? ? nil : Saklient::Cloud::Resources::ServerPlan.new(@_client, Saklient::Util::get_by_path(r, 'ServerPlan'))
  else
    @m_plan = nil
    @is_incomplete = true
  end
  @n_plan = false
  if Saklient::Util::exists_path(r, 'Interfaces')
    if (Saklient::Util::get_by_path(r, 'Interfaces')).nil?
      @m_ifaces = []
    else
      @m_ifaces = []
      for t in Saklient::Util::get_by_path(r, 'Interfaces')
        v2 = nil
        v2 = (t).nil? ? nil : Saklient::Cloud::Resources::Iface.new(@_client, t)
        @m_ifaces << v2
      end
    end
  else
    @m_ifaces = nil
    @is_incomplete = true
  end
  @n_ifaces = false
  if Saklient::Util::exists_path(r, 'Instance')
    @m_instance = (Saklient::Util::get_by_path(r, 'Instance')).nil? ? nil : Saklient::Cloud::Resources::ServerInstance.new(@_client, Saklient::Util::get_by_path(r, 'Instance'))
  else
    @m_instance = nil
    @is_incomplete = true
  end
  @n_instance = false
  if Saklient::Util::exists_path(r, 'HostName')
    @m_host_name = (Saklient::Util::get_by_path(r, 'HostName')).nil? ? nil : Saklient::Util::get_by_path(r, 'HostName').to_s
  else
    @m_host_name = nil
    @is_incomplete = true
  end
  @n_host_name = false
  if Saklient::Util::exists_path(r, 'Availability')
    @m_availability = (Saklient::Util::get_by_path(r, 'Availability')).nil? ? nil : Saklient::Util::get_by_path(r, 'Availability').to_s
  else
    @m_availability = nil
    @is_incomplete = true
  end
  @n_availability = false
end
api_serialize_impl(withClean = false) click to toggle source

@private @param [bool] withClean @return [any]

# File lib/saklient/cloud/resources/server.rb, line 970
def api_serialize_impl(withClean = false)
  Saklient::Util::validate_type(withClean, 'bool')
  missing = []
  ret = {}
  Saklient::Util::set_by_path(ret, 'ID', @m_id) if withClean || @n_id
  if withClean || @n_name
    Saklient::Util::set_by_path(ret, 'Name', @m_name)
  else
    missing << 'name' if @is_new
  end
  Saklient::Util::set_by_path(ret, 'Description', @m_description) if withClean || @n_description
  if withClean || @n_tags
    Saklient::Util::set_by_path(ret, 'Tags', [])
    for r1 in @m_tags
      v = nil
      v = r1
      ret[:Tags] << v
    end
  end
  Saklient::Util::set_by_path(ret, 'Icon', withClean ? ((@m_icon).nil? ? nil : @m_icon.api_serialize(withClean)) : ((@m_icon).nil? ? { ID: '0' } : @m_icon.api_serialize_id)) if withClean || @n_icon
  if withClean || @n_plan
    Saklient::Util::set_by_path(ret, 'ServerPlan', withClean ? ((@m_plan).nil? ? nil : @m_plan.api_serialize(withClean)) : ((@m_plan).nil? ? { ID: '0' } : @m_plan.api_serialize_id))
  else
    missing << 'plan' if @is_new
  end
  if withClean || @n_ifaces
    Saklient::Util::set_by_path(ret, 'Interfaces', [])
    for r2 in @m_ifaces
      v = nil
      v = withClean ? ((r2).nil? ? nil : r2.api_serialize(withClean)) : ((r2).nil? ? { ID: '0' } : r2.api_serialize_id)
      ret[:Interfaces] << v
    end
  end
  Saklient::Util::set_by_path(ret, 'Instance', withClean ? ((@m_instance).nil? ? nil : @m_instance.api_serialize(withClean)) : ((@m_instance).nil? ? { ID: '0' } : @m_instance.api_serialize_id)) if withClean || @n_instance
  Saklient::Util::set_by_path(ret, 'HostName', @m_host_name) if withClean || @n_host_name
  Saklient::Util::set_by_path(ret, 'Availability', @m_availability) if withClean || @n_availability
  raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Server creation: ' + missing.join(', ')) if missing.length > 0
  return ret
end
get_availability() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 853
def get_availability
  return @m_availability
end
get_description() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 603
def get_description
  return @m_description
end
get_host_name() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 813
def get_host_name
  return @m_host_name
end
get_icon() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Icon]

# File lib/saklient/cloud/resources/server.rb, line 684
def get_icon
  return @m_icon
end
get_id() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 539
def get_id
  return @m_id
end
get_ifaces() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Array<Iface>]

# File lib/saklient/cloud/resources/server.rb, line 765
def get_ifaces
  return @m_ifaces
end
get_instance() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [ServerInstance]

# File lib/saklient/cloud/resources/server.rb, line 789
def get_instance
  return @m_instance
end
get_name() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [String]

# File lib/saklient/cloud/resources/server.rb, line 563
def get_name
  return @m_name
end
get_plan() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [ServerPlan]

# File lib/saklient/cloud/resources/server.rb, line 724
def get_plan
  return @m_plan
end
get_tags() click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @return [Array<String>]

# File lib/saklient/cloud/resources/server.rb, line 643
def get_tags
  @n_tags = true
  return @m_tags
end
set_description(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [String] v @return [String]

# File lib/saklient/cloud/resources/server.rb, line 612
def set_description(v)
  Saklient::Util::validate_type(v, 'String')
  @m_description = v
  @n_description = true
  return @m_description
end
set_host_name(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [String] v @return [String]

# File lib/saklient/cloud/resources/server.rb, line 822
def set_host_name(v)
  Saklient::Util::validate_type(v, 'String')
  @m_host_name = v
  @n_host_name = true
  return @m_host_name
end
set_icon(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Icon] v @return [Icon]

# File lib/saklient/cloud/resources/server.rb, line 693
def set_icon(v)
  Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::Icon')
  @m_icon = v
  @n_icon = true
  return @m_icon
end
set_name(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [String] v @return [String]

# File lib/saklient/cloud/resources/server.rb, line 572
def set_name(v)
  Saklient::Util::validate_type(v, 'String')
  @m_name = v
  @n_name = true
  return @m_name
end
set_plan(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [ServerPlan] v @return [ServerPlan]

# File lib/saklient/cloud/resources/server.rb, line 733
def set_plan(v)
  Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::ServerPlan')
  raise Saklient::Errors::SaklientException.new('immutable_field', 'Immutable fields cannot be modified after the resource creation: ' + 'Saklient::Cloud::Resources::Server#plan') if !@is_new
  @m_plan = v
  @n_plan = true
  return @m_plan
end
set_tags(v) click to toggle source

(This method is generated in Translator_default#buildImpl)

@private @param [Array<String>] v @return [Array<String>]

# File lib/saklient/cloud/resources/server.rb, line 653
def set_tags(v)
  Saklient::Util::validate_type(v, 'Array')
  @m_tags = v
  @n_tags = true
  return @m_tags
end
sleep_until(status, timeoutSec = 180) click to toggle source

サーバが指定のステータスに遷移するまで待機します.

@private @param [String] status @param [Fixnum] timeoutSec @return [bool]

# File lib/saklient/cloud/resources/server.rb, line 421
def sleep_until(status, timeoutSec = 180)
  Saklient::Util::validate_type(status, 'String')
  Saklient::Util::validate_type(timeoutSec, 'Fixnum')
  step = 10
  while 0 < timeoutSec do
    begin
      reload
    rescue Saklient::Errors::HttpException
      {}
    end
    s = nil
    inst = self.instance
    s = inst.status if !(inst).nil?
    s = Saklient::Cloud::Enums::EServerInstanceStatus::down if (s).nil?
    return true if s == status
    timeoutSec -= step
    sleep(step) if 0 < timeoutSec
  end
  return false
end