class Saklient::Cloud::Resources::Swytch
スイッチの実体1つに対応し, 属性の取得や操作を行うためのクラス.
Attributes
接続されているブリッジ
@return [Bridge]
説明
@return [String]
アイコン
@return [Icon]
ID
@return [String]
IPv4ネットワーク(ルータによる自動割当) {Ipv4Net} の配列
@return [Array<Ipv4Net>]
IPv6ネットワーク(ルータによる自動割当) {Ipv6Net} の配列
@return [Array<Ipv6Net>]
接続されているブリッジ
@return [Bridge]
説明
@return [String]
アイコン
@return [Icon]
ID
@return [String]
IPv4ネットワーク(ルータによる自動割当) {Ipv4Net} の配列
@return [Array<Ipv4Net>]
IPv6ネットワーク(ルータによる自動割当) {Ipv6Net} の配列
@return [Array<Ipv6Net>]
名前
@return [String]
接続されているルータ
@return [Router]
ユーザ設定IPv4ネットワークのゲートウェイ
@return [String]
ユーザ設定IPv4ネットワークのマスク長
@return [Fixnum]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
@return [bool]
名前
@return [String]
接続されているルータ
@return [Router]
ユーザ設定IPv4ネットワークのゲートウェイ
@return [String]
ユーザ設定IPv4ネットワークのマスク長
@return [Fixnum]
Public Class Methods
@private @param [Saklient::Cloud::Client] client @param [any] obj @param [bool] wrapped
Saklient::Cloud::Resources::Resource::new
# File lib/saklient/cloud/resources/swytch.rb, line 127 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
Public Instance Methods
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 99 def _class_name return 'Swytch' end
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 105 def _id return get_id end
このルータ+スイッチでIPv6アドレスを有効にします.
@return [Ipv6Net] 有効化されたIPv6ネットワーク
# File lib/saklient/cloud/resources/swytch.rb, line 137 def add_ipv6_net ret = get_router.add_ipv6_net reload return ret end
このルータ+スイッチにスタティックルートを追加します.
@param [Fixnum] maskLen @param [String] nextHop @return [Ipv4Net] 追加されたIPv4ネットワーク
# File lib/saklient/cloud/resources/swytch.rb, line 158 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
このルータ+スイッチの帯域プランを変更します.
@param [Fixnum] bandWidthMbps 帯域幅(api.product.router.find() から取得できる {RouterPlan} の bandWidthMbps を指定). @return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 181 def change_plan(bandWidthMbps) Saklient::Util::validate_type(bandWidthMbps, 'Fixnum') get_router.change_plan(bandWidthMbps) reload return self end
このルータ+スイッチで利用できる未使用のIPアドレスを収集します.
@return [Array<String>]
# File lib/saklient/cloud/resources/swytch.rb, line 249 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
このルータ+スイッチに接続中のインタフェースに割り当てられているIPアドレスを収集します.
@return [Array<String>]
# File lib/saklient/cloud/resources/swytch.rb, line 241 def collect_used_ipv4_addresses found = _used_ipv4_address_hash return found.keys.map{|k| k.to_s}.sort() end
このルータ+スイッチをブリッジに接続します.
@param swytch 接続先のブリッジ. @param [Bridge] bridge @return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 193 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
# File lib/saklient/cloud/resources/swytch.rb, line 360 def description=(v) set_description(v) end
このルータ+スイッチをブリッジから切断します.
@return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 203 def disconnect_from_bridge result = @_client.request('DELETE', _api_path + '/' + _id + '/to/bridge') reload return self end
# File lib/saklient/cloud/resources/swytch.rb, line 441 def icon=(v) set_icon(v) end
# File lib/saklient/cloud/resources/swytch.rb, line 320 def name=(v) set_name(v) end
最新のリソース情報を再取得します.
@return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 119 def reload return _reload end
このルータ+スイッチでIPv6アドレスを無効にします.
@return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 146 def remove_ipv6_net nets = get_ipv6_nets get_router.remove_ipv6_net(nets[0]) reload return self end
このルータ+スイッチからスタティックルートを削除します.
@param [Ipv4Net] ipv4Net @return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 170 def remove_static_route(ipv4Net) Saklient::Util::validate_type(ipv4Net, 'Saklient::Cloud::Resources::Ipv4Net') get_router.remove_static_route(ipv4Net) reload return self end
このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
@return [Swytch] this
# File lib/saklient/cloud/resources/swytch.rb, line 112 def save return _save end
Protected Instance Methods
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 79 def _api_path return '/switch' end
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 85 def _root_key return 'Switch' end
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 91 def _root_key_m return 'Switches' end
@private @return [any]
# File lib/saklient/cloud/resources/swytch.rb, line 213 def _used_ipv4_address_hash filter = {} filter[('Switch' + '.ID').to_sym] = _id query = {} Saklient::Util::set_by_path(query, 'Count', 0) Saklient::Util::set_by_path(query, 'Filter', filter) Saklient::Util::set_by_path(query, 'Include', ['IPAddress', 'UserIPAddress']) result = @_client.request('GET', '/interface', query) return nil if (result).nil? result = result[:Interfaces] return nil if (result).nil? ifaces = result return nil if (ifaces).nil? found = {} for iface in ifaces ip = iface[:IPAddress] userIp = iface[:UserIPAddress] ip = userIp if (ip).nil? found[ip.to_sym] = true if !(ip).nil? end return found end
(This method is generated in Translator_default#buildImpl)
@param [any] r
# File lib/saklient/cloud/resources/swytch.rb, line 594 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, 'UserSubnet.DefaultRoute') @m_user_default_route = (Saklient::Util::get_by_path(r, 'UserSubnet.DefaultRoute')).nil? ? nil : Saklient::Util::get_by_path(r, 'UserSubnet.DefaultRoute').to_s else @m_user_default_route = nil @is_incomplete = true end @n_user_default_route = false if Saklient::Util::exists_path(r, 'UserSubnet.NetworkMaskLen') @m_user_mask_len = (Saklient::Util::get_by_path(r, 'UserSubnet.NetworkMaskLen')).nil? ? nil : (Saklient::Util::get_by_path(r, 'UserSubnet.NetworkMaskLen').to_s).to_s().to_i(10) else @m_user_mask_len = nil @is_incomplete = true end @n_user_mask_len = false if Saklient::Util::exists_path(r, 'Internet') @m_router = (Saklient::Util::get_by_path(r, 'Internet')).nil? ? nil : Saklient::Cloud::Resources::Router.new(@_client, Saklient::Util::get_by_path(r, 'Internet')) else @m_router = nil @is_incomplete = true end @n_router = false if Saklient::Util::exists_path(r, 'Bridge') @m_bridge = (Saklient::Util::get_by_path(r, 'Bridge')).nil? ? nil : Saklient::Cloud::Resources::Bridge.new(@_client, Saklient::Util::get_by_path(r, 'Bridge')) else @m_bridge = nil @is_incomplete = true end @n_bridge = false if Saklient::Util::exists_path(r, 'Subnets') if (Saklient::Util::get_by_path(r, 'Subnets')).nil? @m_ipv4_nets = [] else @m_ipv4_nets = [] for t in Saklient::Util::get_by_path(r, 'Subnets') v2 = nil v2 = (t).nil? ? nil : Saklient::Cloud::Resources::Ipv4Net.new(@_client, t) @m_ipv4_nets << v2 end end else @m_ipv4_nets = nil @is_incomplete = true end @n_ipv4_nets = false if Saklient::Util::exists_path(r, 'IPv6Nets') if (Saklient::Util::get_by_path(r, 'IPv6Nets')).nil? @m_ipv6_nets = [] else @m_ipv6_nets = [] for t in Saklient::Util::get_by_path(r, 'IPv6Nets') v3 = nil v3 = (t).nil? ? nil : Saklient::Cloud::Resources::Ipv6Net.new(@_client, t) @m_ipv6_nets << v3 end end else @m_ipv6_nets = nil @is_incomplete = true end @n_ipv6_nets = false end
@private @param [bool] withClean @return [any]
# File lib/saklient/cloud/resources/swytch.rb, line 707 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 Saklient::Util::set_by_path(ret, 'UserSubnet.DefaultRoute', @m_user_default_route) if withClean || @n_user_default_route Saklient::Util::set_by_path(ret, 'UserSubnet.NetworkMaskLen', @m_user_mask_len) if withClean || @n_user_mask_len Saklient::Util::set_by_path(ret, 'Internet', withClean ? ((@m_router).nil? ? nil : @m_router.api_serialize(withClean)) : ((@m_router).nil? ? { ID: '0' } : @m_router.api_serialize_id)) if withClean || @n_router Saklient::Util::set_by_path(ret, 'Bridge', withClean ? ((@m_bridge).nil? ? nil : @m_bridge.api_serialize(withClean)) : ((@m_bridge).nil? ? { ID: '0' } : @m_bridge.api_serialize_id)) if withClean || @n_bridge if withClean || @n_ipv4_nets Saklient::Util::set_by_path(ret, 'Subnets', []) for r2 in @m_ipv4_nets v = nil v = withClean ? ((r2).nil? ? nil : r2.api_serialize(withClean)) : ((r2).nil? ? { ID: '0' } : r2.api_serialize_id) ret[:Subnets] << v end end if withClean || @n_ipv6_nets Saklient::Util::set_by_path(ret, 'IPv6Nets', []) for r3 in @m_ipv6_nets v = nil v = withClean ? ((r3).nil? ? nil : r3.api_serialize(withClean)) : ((r3).nil? ? { ID: '0' } : r3.api_serialize_id) ret[:IPv6Nets] << v end end raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Swytch creation: ' + missing.join(', ')) if missing.length > 0 return ret end
(This method is generated in Translator_default#buildImpl)
@private @return [Bridge]
# File lib/saklient/cloud/resources/swytch.rb, line 526 def get_bridge return @m_bridge end
(This method is generated in Translator_default#buildImpl)
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 333 def get_description return @m_description end
(This method is generated in Translator_default#buildImpl)
@private @return [Icon]
# File lib/saklient/cloud/resources/swytch.rb, line 414 def get_icon return @m_icon end
(This method is generated in Translator_default#buildImpl)
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 269 def get_id return @m_id end
(This method is generated in Translator_default#buildImpl)
@private @return [Array<Ipv4Net>]
# File lib/saklient/cloud/resources/swytch.rb, line 550 def get_ipv4_nets return @m_ipv4_nets end
(This method is generated in Translator_default#buildImpl)
@private @return [Array<Ipv6Net>]
# File lib/saklient/cloud/resources/swytch.rb, line 574 def get_ipv6_nets return @m_ipv6_nets end
(This method is generated in Translator_default#buildImpl)
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 293 def get_name return @m_name end
(This method is generated in Translator_default#buildImpl)
@private @return [Router]
# File lib/saklient/cloud/resources/swytch.rb, line 502 def get_router return @m_router end
(This method is generated in Translator_default#buildImpl)
@private @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 454 def get_user_default_route return @m_user_default_route end
(This method is generated in Translator_default#buildImpl)
@private @return [Fixnum]
# File lib/saklient/cloud/resources/swytch.rb, line 478 def get_user_mask_len return @m_user_mask_len end
(This method is generated in Translator_default#buildImpl)
@private @param [String] v @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 342 def set_description(v) Saklient::Util::validate_type(v, 'String') @m_description = v @n_description = true return @m_description end
(This method is generated in Translator_default#buildImpl)
@private @param [Icon] v @return [Icon]
# File lib/saklient/cloud/resources/swytch.rb, line 423 def set_icon(v) Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::Icon') @m_icon = v @n_icon = true return @m_icon end
(This method is generated in Translator_default#buildImpl)
@private @param [String] v @return [String]
# File lib/saklient/cloud/resources/swytch.rb, line 302 def set_name(v) Saklient::Util::validate_type(v, 'String') @m_name = v @n_name = true return @m_name end