简体   繁体   中英

How to change port group properties in vcenter,e.g., like blocking a specific port of virtual port group by MAC address

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM