Reputation: 119
I want to write a script that accepts a virtual port group name and a MAC address, based on which I want to block a certain port of that Virtual Port Group. Is there any way of doing it using pysphere APIs?
Upvotes: 0
Views: 177
Reputation: 119
I was able to achieve this using ReconfigureDVPort_Task API.
new_request = VI.ReconfigureDVPort_TaskRequestMsg()
all_switches = self.server._get_managed_objects(MORTypes.DistributedVirtualSwitch, from_mor=nfmor)
_this = new_request.new__this(all_switches.keys()[0])
_this.set_attribute_type(all_switches.keys()[0].get_attribute_type())
new_request.set_element__this(_this)
port = new_request.new_port()
setting = port.new_setting()
blocked = setting.new_blocked()
blocked.set_element_value(True)
blocked.set_element_inherited(False)
setting.set_element_blocked(blocked)
port.set_element_key(required_port.Key)
port.set_element_setting(setting)
port.set_element_operation('edit')
new_request.set_element_port([port])
ret = self.server._proxy.ReconfigureDVPort_Task(new_request)._returnval
Upvotes: 0