Class: Saklient::Cloud::Resources::Swytch
- Defined in:
- lib/saklient/cloud/resources/swytch.rb
Overview
スイッチの実体1つに対応し, 属性の取得や操作を行うためのクラス.
Instance Attribute Summary collapse
-
#bridge ⇒ Bridge
readonly
接続されているブリッジ.
-
#description ⇒ String
説明.
-
#icon ⇒ Icon
アイコン.
-
#id ⇒ String
readonly
ID.
-
#ipv4_nets ⇒ Array<Ipv4Net>
readonly
IPv4ネットワーク(ルータによる自動割当) Ipv4Net の配列.
-
#ipv6_nets ⇒ Array<Ipv6Net>
readonly
IPv6ネットワーク(ルータによる自動割当) Ipv6Net の配列.
-
#name ⇒ String
名前.
-
#router ⇒ Router
readonly
接続されているルータ.
-
#tags ⇒ Array<String>
タグ文字列の配列.
-
#user_default_route ⇒ String
readonly
ユーザ設定IPv4ネットワークのゲートウェイ.
-
#user_mask_len ⇒ Fixnum
readonly
ユーザ設定IPv4ネットワークのマスク長.
Attributes inherited from Resource
Instance Method Summary collapse
- #_class_name ⇒ String
- #_id ⇒ String
-
#add_ipv6_net ⇒ Ipv6Net
このルータ+スイッチでIPv6アドレスを有効にします.
-
#add_static_route(maskLen, nextHop) ⇒ Ipv4Net
このルータ+スイッチにスタティックルートを追加します.
-
#change_plan(bandWidthMbps) ⇒ Swytch
このルータ+スイッチの帯域プランを変更します.
-
#collect_unused_ipv4_addresses ⇒ Array<String>
このルータ+スイッチで利用できる未使用のIPアドレスを収集します.
-
#collect_used_ipv4_addresses ⇒ Array<String>
このルータ+スイッチに接続中のインタフェースに割り当てられているIPアドレスを収集します.
-
#connect_to_bridge(bridge) ⇒ Swytch
このルータ+スイッチをブリッジに接続します.
-
#disconnect_from_bridge ⇒ Swytch
このルータ+スイッチをブリッジから切断します.
-
#initialize(client, obj, wrapped = false) ⇒ Swytch
constructor
A new instance of Swytch.
-
#reload ⇒ Swytch
最新のリソース情報を再取得します.
-
#remove_ipv6_net ⇒ Swytch
このルータ+スイッチでIPv6アドレスを無効にします.
-
#remove_static_route(ipv4Net) ⇒ Swytch
このルータ+スイッチからスタティックルートを削除します.
-
#save ⇒ Swytch
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
Methods inherited from Resource
#api_deserialize, #api_serialize, create_with, #destroy, #dump, #exists, #request_retry, #set_param
Constructor Details
#initialize(client, obj, wrapped = false) ⇒ Swytch
Returns a new instance of Swytch.
128 129 130 131 132 133 |
# File 'lib/saklient/cloud/resources/swytch.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') api_deserialize(obj, wrapped) end |
Instance Attribute Details
#bridge ⇒ Bridge (readonly)
接続されているブリッジ
536 537 538 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 536 def bridge @bridge end |
#description ⇒ String
説明
355 356 357 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 355 def description @description end |
#icon ⇒ Icon
アイコン
436 437 438 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 436 def icon @icon end |
#id ⇒ String (readonly)
ID
279 280 281 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 279 def id @id end |
#ipv4_nets ⇒ Array<Ipv4Net> (readonly)
IPv4ネットワーク(ルータによる自動割当) Ipv4Net の配列
560 561 562 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 560 def ipv4_nets @ipv4_nets end |
#ipv6_nets ⇒ Array<Ipv6Net> (readonly)
IPv6ネットワーク(ルータによる自動割当) Ipv6Net の配列
584 585 586 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 584 def ipv6_nets @ipv6_nets end |
#name ⇒ String
名前
315 316 317 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 315 def name @name end |
#router ⇒ Router (readonly)
接続されているルータ
512 513 514 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 512 def router @router end |
#tags ⇒ Array<String>
タグ文字列の配列
396 397 398 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 396 def @tags end |
#user_default_route ⇒ String (readonly)
ユーザ設定IPv4ネットワークのゲートウェイ
464 465 466 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 464 def user_default_route @user_default_route end |
#user_mask_len ⇒ Fixnum (readonly)
ユーザ設定IPv4ネットワークのマスク長
488 489 490 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 488 def user_mask_len @user_mask_len end |
Instance Method Details
#_class_name ⇒ String
100 101 102 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 100 def _class_name return 'Swytch' end |
#_id ⇒ String
106 107 108 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 106 def _id return get_id end |
#add_ipv6_net ⇒ Ipv6Net
このルータ+スイッチでIPv6アドレスを有効にします.
138 139 140 141 142 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 138 def add_ipv6_net ret = get_router.add_ipv6_net reload return ret end |
#add_static_route(maskLen, nextHop) ⇒ Ipv4Net
このルータ+スイッチにスタティックルートを追加します.
159 160 161 162 163 164 165 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 159 def add_static_route(maskLen, nextHop) Saklient::Util::validate_type(maskLen, 'Fixnum') Saklient::Util::validate_type(nextHop, 'String') ret = get_router.add_static_route(maskLen, nextHop) reload return ret end |
#change_plan(bandWidthMbps) ⇒ Swytch
このルータ+スイッチの帯域プランを変更します.
182 183 184 185 186 187 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 182 def change_plan(bandWidthMbps) Saklient::Util::validate_type(bandWidthMbps, 'Fixnum') get_router.change_plan(bandWidthMbps) reload return self end |
#collect_unused_ipv4_addresses ⇒ Array<String>
このルータ+スイッチで利用できる未使用のIPアドレスを収集します.
250 251 252 253 254 255 256 257 258 259 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 250 def collect_unused_ipv4_addresses nets = get_ipv4_nets return nil if nets.length < 1 used = _used_ipv4_address_hash ret = [] for ip in nets[0].get_range.get_as_array ret << ip if !(!used.nil? && used.key?(ip.to_sym)) end return ret.sort() end |
#collect_used_ipv4_addresses ⇒ Array<String>
このルータ+スイッチに接続中のインタフェースに割り当てられているIPアドレスを収集します.
242 243 244 245 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 242 def collect_used_ipv4_addresses found = _used_ipv4_address_hash return found.keys.map{|k| k.to_s}.sort() end |
#connect_to_bridge(bridge) ⇒ Swytch
このルータ+スイッチをブリッジに接続します.
194 195 196 197 198 199 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 194 def connect_to_bridge(bridge) Saklient::Util::validate_type(bridge, 'Saklient::Cloud::Resources::Bridge') result = @_client.request('PUT', _api_path + '/' + _id + '/to/bridge/' + bridge._id) reload return self end |
#disconnect_from_bridge ⇒ Swytch
このルータ+スイッチをブリッジから切断します.
204 205 206 207 208 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 204 def disconnect_from_bridge result = @_client.request('DELETE', _api_path + '/' + _id + '/to/bridge') reload return self end |
#reload ⇒ Swytch
最新のリソース情報を再取得します.
120 121 122 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 120 def reload return _reload end |
#remove_ipv6_net ⇒ Swytch
このルータ+スイッチでIPv6アドレスを無効にします.
147 148 149 150 151 152 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 147 def remove_ipv6_net nets = get_ipv6_nets get_router.remove_ipv6_net(nets[0]) reload return self end |
#remove_static_route(ipv4Net) ⇒ Swytch
このルータ+スイッチからスタティックルートを削除します.
171 172 173 174 175 176 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 171 def remove_static_route(ipv4Net) Saklient::Util::validate_type(ipv4Net, 'Saklient::Cloud::Resources::Ipv4Net') get_router.remove_static_route(ipv4Net) reload return self end |
#save ⇒ Swytch
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
113 114 115 |
# File 'lib/saklient/cloud/resources/swytch.rb', line 113 def save return _save end |