Class: Saklient::Cloud::Resources::Swytch

Inherits:
Resource
  • Object
show all
Defined in:
lib/saklient/cloud/resources/swytch.rb

Overview

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Bridge) bridge (readonly)

接続されているブリッジ

Returns:



536
537
538
# File 'lib/saklient/cloud/resources/swytch.rb', line 536

def bridge
  @bridge
end

- (String) description

説明

Returns:

  • (String)


355
356
357
# File 'lib/saklient/cloud/resources/swytch.rb', line 355

def description
  @description
end

- (Icon) icon

アイコン

Returns:



436
437
438
# File 'lib/saklient/cloud/resources/swytch.rb', line 436

def icon
  @icon
end

- (String) id (readonly)

ID

Returns:

  • (String)


279
280
281
# File 'lib/saklient/cloud/resources/swytch.rb', line 279

def id
  @id
end

- (Array<Ipv4Net>) ipv4_nets (readonly)

IPv4ネットワーク(ルータによる自動割当) Ipv4Net の配列

Returns:



560
561
562
# File 'lib/saklient/cloud/resources/swytch.rb', line 560

def ipv4_nets
  @ipv4_nets
end

- (Array<Ipv6Net>) ipv6_nets (readonly)

IPv6ネットワーク(ルータによる自動割当) Ipv6Net の配列

Returns:



584
585
586
# File 'lib/saklient/cloud/resources/swytch.rb', line 584

def ipv6_nets
  @ipv6_nets
end

- (String) name

名前

Returns:

  • (String)


315
316
317
# File 'lib/saklient/cloud/resources/swytch.rb', line 315

def name
  @name
end

- (Router) router (readonly)

接続されているルータ

Returns:



512
513
514
# File 'lib/saklient/cloud/resources/swytch.rb', line 512

def router
  @router
end

- (Array<String>) tags

タグ文字列の配列

Returns:

  • (Array<String>)


396
397
398
# File 'lib/saklient/cloud/resources/swytch.rb', line 396

def tags
  @tags
end

- (String) user_default_route (readonly)

ユーザ設定IPv4ネットワークのゲートウェイ

Returns:

  • (String)


464
465
466
# File 'lib/saklient/cloud/resources/swytch.rb', line 464

def user_default_route
  @user_default_route
end

- (Fixnum) user_mask_len (readonly)

ユーザ設定IPv4ネットワークのマスク長

Returns:

  • (Fixnum)


488
489
490
# File 'lib/saklient/cloud/resources/swytch.rb', line 488

def user_mask_len
  @user_mask_len
end

Instance Method Details

- (Ipv6Net) add_ipv6_net

このルータ+スイッチでIPv6アドレスを有効にします.

Returns:

  • (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

- (Ipv4Net) add_static_route(maskLen, nextHop)

このルータ+スイッチにスタティックルートを追加します.

Parameters:

  • maskLen (Fixnum)
  • nextHop (String)

Returns:

  • (Ipv4Net)

    追加されたIPv4ネットワーク



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

- (Swytch) change_plan(bandWidthMbps)

このルータ+スイッチの帯域プランを変更します.

Parameters:

  • bandWidthMbps (Fixnum)

    帯域幅(api.product.router.find() から取得できる RouterPlan の bandWidthMbps を指定).

Returns:



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

- (Array<String>) collect_unused_ipv4_addresses

このルータ+スイッチで利用できる未使用のIPアドレスを収集します.

Returns:

  • (Array<String>)


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

- (Array<String>) collect_used_ipv4_addresses

このルータ+スイッチに接続中のインタフェースに割り当てられているIPアドレスを収集します.

Returns:

  • (Array<String>)


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

- (Swytch) connect_to_bridge(bridge)

このルータ+スイッチをブリッジに接続します.

Parameters:

  • swytch

    接続先のブリッジ.

  • bridge (Bridge)

Returns:



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

- (Swytch) disconnect_from_bridge

このルータ+スイッチをブリッジから切断します.

Returns:



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

- (Swytch) reload

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

Returns:



120
121
122
# File 'lib/saklient/cloud/resources/swytch.rb', line 120

def reload
  return _reload
end

- (Swytch) remove_ipv6_net

このルータ+スイッチでIPv6アドレスを無効にします.

Returns:



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

- (Swytch) remove_static_route(ipv4Net)

このルータ+スイッチからスタティックルートを削除します.

Parameters:

Returns:



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

- (Swytch) save

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

Returns:



113
114
115
# File 'lib/saklient/cloud/resources/swytch.rb', line 113

def save
  return _save
end