2016-07-22 5 views
0

私はsoftlayer APIを使用してトランクを取得/削除/追加しようとしました。 http://sldn.softlayer.com/reference/services/SoftLayer_Network_ComponentSoftlayer API for VLAN Trunk

私たちのベアメタルは、既にSoftlayerチケットでトランケートされています。私たちはまずトランクを外したいと思っています。トランクを追加します。

baremetal uplinkComponent IDを使用してNetworkVlanTrunksを取得できました。ここで client['SoftLayer_Network_Component'].getNetworkVlanTrunks(id=networkcomponentId)

トランクを取得する出力されています。今、私たちは、VLANID-2のトランクを削除したい

[{'networkComponentId': <networkcomponentId>, 'networkVlanId': <vlanid-1>}, {'networkComponentId': <networkcomponentId>, 'networkVlanId': <vlanid-2>}]

vlan = client['Network_Vlan'].getObject(id=<vlanid-2>) client['SoftLayer_Network_Component'].removeNetworkVlanTrunks([vlan], id=networkcomponentId)

しかし、我々はremoveNetworkVlanTrunksたときに、このエラーを得た:

File "/usr/lib64/python2.7/site-packages/SoftLayer/transports.py", line 187, in __call__ raise _ex(ex.faultCode, ex.faultString) SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_InternalError): An internal system error has occurred.

はこれが起こるのかについて、誰を知っていますか? 削除に正しいnetworkComponentIDを使用していますか? 誰かがaddNetworkVlanTrunksの使い方を知っていますか?

+0

コードのフォーマットについては、より注意が必要です。http://stackoverflow.com/editing-help#comment-formatting –

答えて

0

は、VLANが追加または削除に成功した場合は、次のPythonスクリプト試す確認するには:

""" 
This script removes the network vlan trunks from network component 

See below references for more details. 
Important manual pages: 
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Component/addNetworkVlanTrunks 

@License: http://sldn.softlayer.com/article/License 
@Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 
import SoftLayer 
from pprint import pprint as pp 

# Your SoftLayer username and apiKey 
user = 'set me' 
api = 'set me' 

# Connect to SoftLayer 
client = SoftLayer.create_client_from_env(username=user, api_key=api) 

# Define the network component id 
networkComponentId = 916616 

# Define the network vlans that you wish to remove 
networkVlans = [{"id": 1318157}] 

try: 
    result = client['SoftLayer_Network_Component'].removeNetworkVlanTrunks(networkVlans, id=networkComponentId) 
    pp(result) 
except SoftLayer.SoftLayerAPIError as e: 
    print('Error faultCode=%s, faultString=%s' 
      % (e.faultCode, e.faultString)) 
    exit(1) 

""" 
This script removes the network vlan trunks from network component 

See below references for more details. 
Important manual pages: 
http://sldn.softlayer.com/reference/services/SoftLayer_Network_Component/addNetworkVlanTrunks 

@License: http://sldn.softlayer.com/article/License 
@Author: SoftLayer Technologies, Inc. <[email protected]> 
""" 
import SoftLayer 
from pprint import pprint as pp 

# Your SoftLayer username and apiKey 
user = 'set me' 
api = 'set me' 

# Connect to SoftLayer 
client = SoftLayer.create_client_from_env(username=user, api_key=api) 

# Define the network component id 
networkComponentId = 916616 

# Define the network vlans that you wish to remove 
networkVlans = [{"id": 1318157}] 

try: 
    result = client['SoftLayer_Network_Component'].removeNetworkVlanTrunks(networkVlans, id=networkComponentId) 
    pp(result) 
except SoftLayer.SoftLayerAPIError as e: 
    print('Error faultCode=%s, faultString=%s' 
      % (e.faultCode, e.faultString)) 
    exit(1) 

は、ネットワークコンポーネントからVLANトランクを削除するには、以下を試してみてください

ネットワークVLANトランクを追加する方法は、削除する方法と同じですが、とにかくここには方法があります。

私はそれが役に立てば幸い。問題があるか疑問がある場合は教えてください。

+0

私はあなたのコードを試しました。しかし、トランクを取り外すときには内部エラーが発生します。 'networkcomponentId = 5253429 networkVlans = [{ "ID":1231207}] 試み: removetrunk = network_component.removeNetworkVlanTrunks(networkVlans、ID = networkcomponentId) SoftLayer.SoftLayerAPIError以外Eとして: プリント( 'エラーにfaultCode =%sの、errorString =%s ' %(e.faultCode、e.faultString) exit(1) ' – yqdou

+0

エラー例外は次のとおりです:' Error faultCode = SoftLayer_Exception_InternalError、faultString =内部システムエラーが発生しました。' – yqdou

+0

その例外許可またはデバイスアクセスに関連しています。 ** [ハードウェアの詳細を表示する] **アクセス許可が有効で、ネットワークコンポーネントが所属するハードウェア**デバイスに適切なアクセス権があることを確認してください。 –

関連する問題