Skip to content

Commit

Permalink
added python script to do trunking for bms
Browse files Browse the repository at this point in the history
  • Loading branch information
jimccann-rh committed Jun 13, 2023
1 parent c233560 commit 8049f3c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions setupvlantrunking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import SoftLayer
import json
import os

from SoftLayer import VSManager, Client, NetworkManager,HardwareManager

# Set the username and API key
username = "apikey"
api_key = os.environ["IBMCLOUD_API_KEY"]

# Get the SoftLayer API client
client = SoftLayer.Client(username=username, api_key=api_key)

# Print the user's ID
print(SoftLayer.Client)
resp = client.call('Account', 'getObject')
print(resp['companyName'])

vs = VSManager(client)
#print(vs.list_instances())

#SoftLayer.managers.network.NetworkManager
network = NetworkManager(client)

data = network.list_vlans(name="devqe-segment-*")
#data = network.list_vlans(name="devqe-segment-227")
#print(data)
#print(data[0])
#print(data[0]['id'])
#print(data[0]['name'])

# Print the name of each VLAN
for i in data:
print(i['name'])
print(i['id'])
print(i['vlanNumber'])
networkvlanid = [{'id': i['id']}]
hardware = HardwareManager(client)

data2 = hardware.list_hardware(hostname="devqe-vmware-host-*")


# print(data2)
# print(data2[0]['hostname'])


for j in data2:
print(j['hostname'])
print(j['id'])
bmsid = j['id']
data3 = hardware.get_hardware(hardware_id=bmsid)
# print(data3)
print(data3['networkComponents'])
print(data3['networkComponents'][1])
print(data3['networkComponents'][1]['id'])
bmsnetworkid = data3['networkComponents'][1]['id']
trunkVlan = client['SoftLayer_Network_Component'].addNetworkVlanTrunks(networkvlanid, id=bmsnetworkid)

0 comments on commit 8049f3c

Please sign in to comment.