Class: Saklient::Cloud::Resources::Router
- Defined in:
- lib/saklient/cloud/resources/router.rb
Overview
ルータの実体1つに対応し, 属性の取得や操作を行うためのクラス.
Instance Attribute Summary collapse
-
#activity ⇒ RouterActivity
readonly
アクティビティ.
-
#band_width_mbps ⇒ Fixnum
帯域幅.
-
#description ⇒ String
説明.
-
#id ⇒ String
readonly
ID.
-
#name ⇒ String
名前.
-
#network_mask_len ⇒ Fixnum
ネットワークのマスク長.
-
#swytch_id ⇒ String
readonly
スイッチ.
Attributes inherited from Resource
Instance Method Summary collapse
- #_class_name ⇒ String
- #_id ⇒ String
-
#add_ipv6_net ⇒ Ipv6Net
このルータ+スイッチでIPv6アドレスを有効にします.
-
#add_static_route(maskLen, nextHop) ⇒ Ipv4Net
このルータ+スイッチにスタティックルートを追加します.
-
#after_create(timeoutSec) {|Saklient::Cloud::Resources::Router, bool| ... } ⇒ void
作成中のルータが利用可能になるまで待機します.
-
#change_plan(bandWidthMbps) ⇒ Router
このルータ+スイッチの帯域プランを変更します.
- #get_activity ⇒ RouterActivity
-
#get_swytch ⇒ Swytch
このルータが接続されているスイッチを取得します.
-
#initialize(client, obj, wrapped = false) ⇒ Router
constructor
A new instance of Router.
-
#reload ⇒ Router
最新のリソース情報を再取得します.
-
#remove_ipv6_net(ipv6Net) ⇒ Router
このルータ+スイッチでIPv6アドレスを無効にします.
-
#remove_static_route(ipv4Net) ⇒ Router
このルータ+スイッチからスタティックルートを削除します.
-
#save ⇒ Router
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
-
#sleep_while_creating(timeoutSec = 120) ⇒ bool
作成中のルータが利用可能になるまで待機します.
Methods inherited from Resource
#api_deserialize, #api_serialize, create_with, #destroy, #dump, #exists, #request_retry, #set_param
Constructor Details
#initialize(client, obj, wrapped = false) ⇒ Router
Returns a new instance of Router.
128 129 130 131 132 133 134 |
# File 'lib/saklient/cloud/resources/router.rb', line 128 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::RouterActivity.new(client) api_deserialize(obj, wrapped) end |
Instance Attribute Details
#activity ⇒ RouterActivity (readonly)
アクティビティ
118 119 120 |
# File 'lib/saklient/cloud/resources/router.rb', line 118 def activity @activity end |
#band_width_mbps ⇒ Fixnum
帯域幅
434 435 436 |
# File 'lib/saklient/cloud/resources/router.rb', line 434 def band_width_mbps @band_width_mbps end |
#description ⇒ String
説明
352 353 354 |
# File 'lib/saklient/cloud/resources/router.rb', line 352 def description @description end |
#id ⇒ String (readonly)
ID
276 277 278 |
# File 'lib/saklient/cloud/resources/router.rb', line 276 def id @id end |
#name ⇒ String
名前
312 313 314 |
# File 'lib/saklient/cloud/resources/router.rb', line 312 def name @name end |
#network_mask_len ⇒ Fixnum
ネットワークのマスク長
393 394 395 |
# File 'lib/saklient/cloud/resources/router.rb', line 393 def network_mask_len @network_mask_len end |
#swytch_id ⇒ String (readonly)
スイッチ
462 463 464 |
# File 'lib/saklient/cloud/resources/router.rb', line 462 def swytch_id @swytch_id end |
Instance Method Details
#_class_name ⇒ String
77 78 79 |
# File 'lib/saklient/cloud/resources/router.rb', line 77 def _class_name return 'Router' end |
#_id ⇒ String
83 84 85 |
# File 'lib/saklient/cloud/resources/router.rb', line 83 def _id return get_id end |
#add_ipv6_net ⇒ Ipv6Net
このルータ+スイッチでIPv6アドレスを有効にします.
198 199 200 201 202 |
# File 'lib/saklient/cloud/resources/router.rb', line 198 def add_ipv6_net result = @_client.request('POST', _api_path + '/' + Saklient::Util::url_encode(_id) + '/ipv6net') reload return Saklient::Cloud::Resources::Ipv6Net.new(@_client, result[:IPv6Net]) end |
#add_static_route(maskLen, nextHop) ⇒ Ipv4Net
このルータ+スイッチにスタティックルートを追加します.
220 221 222 223 224 225 226 227 228 229 |
# File 'lib/saklient/cloud/resources/router.rb', line 220 def add_static_route(maskLen, nextHop) Saklient::Util::validate_type(maskLen, 'Fixnum') Saklient::Util::validate_type(nextHop, 'String') q = {} Saklient::Util::set_by_path(q, 'NetworkMaskLen', maskLen) Saklient::Util::set_by_path(q, 'NextHop', nextHop) result = @_client.request('POST', _api_path + '/' + Saklient::Util::url_encode(_id) + '/subnet', q) reload return Saklient::Cloud::Resources::Ipv4Net.new(@_client, result[:Subnet]) end |
#after_create(timeoutSec) {|Saklient::Cloud::Resources::Router, bool| ... } ⇒ void
This method returns an undefined value.
作成中のルータが利用可能になるまで待機します.
155 156 157 158 159 160 |
# File 'lib/saklient/cloud/resources/router.rb', line 155 def after_create(timeoutSec, &callback) Saklient::Util::validate_type(timeoutSec, 'Fixnum') Saklient::Util::validate_type(callback, 'Proc') ret = sleep_while_creating(timeoutSec) callback.call(self, ret) end |
#change_plan(bandWidthMbps) ⇒ Router
このルータ+スイッチの帯域プランを変更します.
成功時はリソースIDが変わることにご注意ください.
248 249 250 251 252 253 254 255 256 |
# File 'lib/saklient/cloud/resources/router.rb', line 248 def change_plan(bandWidthMbps) Saklient::Util::validate_type(bandWidthMbps, 'Fixnum') path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/bandwidth' q = {} Saklient::Util::set_by_path(q, 'Internet.BandWidthMbps', bandWidthMbps) result = @_client.request('PUT', path, q) api_deserialize(result, true) return self end |
#get_activity ⇒ RouterActivity
111 112 113 |
# File 'lib/saklient/cloud/resources/router.rb', line 111 def get_activity return @_activity end |
#get_swytch ⇒ Swytch
このルータが接続されているスイッチを取得します.
189 190 191 192 193 |
# File 'lib/saklient/cloud/resources/router.rb', line 189 def get_swytch model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Swytch', [@_client]) id = get_swytch_id return model.get_by_id(id) end |
#reload ⇒ Router
最新のリソース情報を再取得します.
97 98 99 |
# File 'lib/saklient/cloud/resources/router.rb', line 97 def reload return _reload end |
#remove_ipv6_net(ipv6Net) ⇒ Router
このルータ+スイッチでIPv6アドレスを無効にします.
208 209 210 211 212 213 |
# File 'lib/saklient/cloud/resources/router.rb', line 208 def remove_ipv6_net(ipv6Net) Saklient::Util::validate_type(ipv6Net, 'Saklient::Cloud::Resources::Ipv6Net') @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/ipv6net/' + ipv6Net._id) reload return self end |
#remove_static_route(ipv4Net) ⇒ Router
このルータ+スイッチからスタティックルートを削除します.
235 236 237 238 239 240 |
# File 'lib/saklient/cloud/resources/router.rb', line 235 def remove_static_route(ipv4Net) Saklient::Util::validate_type(ipv4Net, 'Saklient::Cloud::Resources::Ipv4Net') @_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/subnet/' + ipv4Net._id) reload return self end |
#save ⇒ Router
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
90 91 92 |
# File 'lib/saklient/cloud/resources/router.rb', line 90 def save return _save end |
#sleep_while_creating(timeoutSec = 120) ⇒ bool
作成中のルータが利用可能になるまで待機します.
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/saklient/cloud/resources/router.rb', line 166 def sleep_while_creating(timeoutSec = 120) Saklient::Util::validate_type(timeoutSec, 'Fixnum') step = 3 isOk = false while 0 < timeoutSec do begin if exists reload isOk = true end rescue Saklient::Errors::HttpException {} end timeoutSec -= step timeoutSec = 0 if isOk sleep(step) if 0 < timeoutSec end return isOk end |