Exemple #1
0
    def make_pg(self, vswitch, pg_name, vlan, uplink="lag1"):
        """
        Create a new Port Group on a vSwitch.

        Arguments:
        :param vswitch: the vSwitch on which to make the port group
                (see `get_vdswitch`)
        :param pg_name: the name for the new distributed port group
        :param vlan: the VLAN ID for the new distributed port group
        :param uplink: the name of the uplink to use
        """
        spec = vim.DVPortgroupConfigSpec()
        spec.name = pg_name
        spec.numPorts = 32
        spec.type = vim.DistributedVirtualPortgroupPortgroupType.earlyBinding
        cfg = vim.VMwareDVSPortSetting()
        cfg.vlan = vim.VmwareDistributedVirtualSwitchVlanIdSpec()
        cfg.vlan.vlanId = vlan
        cfg.vlan.inherited = False
        policy = vim.VmwareUplinkPortTeamingPolicy()
        policy.uplinkPortOrder = vim.VMwareUplinkPortOrderPolicy()
        policy.uplinkPortOrder.activeUplinkPort = [uplink]
        policy.uplinkPortOrder.standbyUplinkPort = []
        cfg.uplinkTeamingPolicy = policy
        cfg.securityPolicy = vim.DVSSecurityPolicy()
        cfg.securityPolicy.allowPromiscuous = vim.BoolPolicy(value=True)
        cfg.securityPolicy.forgedTransmits = vim.BoolPolicy(value=True)
        cfg.securityPolicy.macChanges = vim.BoolPolicy(value=False)
        cfg.securityPolicy.inherited = False
        spec.defaultPortConfig = cfg
        self.wait_for_tasks([vswitch.AddDVPortgroup_Task([spec])])
Exemple #2
0
    def create_port_group(self):
        config = vim.dvs.DistributedVirtualPortgroup.ConfigSpec()

        config.name = self.portgroup_name
        config.numPorts = self.num_ports

        # vim.VMwareDVSPortSetting() does not exist in the pyvmomi documentation
        # but this is the correct managed object type.

        config.defaultPortConfig = vim.VMwareDVSPortSetting()

        # vim.VmwareDistributedVirtualSwitchVlanIdSpec() does not exist in the
        # pyvmomi documentation but this is the correct managed object type
        config.defaultPortConfig.vlan = vim.VmwareDistributedVirtualSwitchVlanIdSpec()
        config.defaultPortConfig.vlan.inherited = False
        config.defaultPortConfig.vlan.vlanId = self.vlan_id
        config.type = self.portgroup_type

        spec = [config]
        task = self.dv_switch.AddDVPortgroup_Task(spec)
        changed, result = wait_for_task(task)
        return changed, result
Exemple #3
0
    def create_port_group(self):
        config = vim.dvs.DistributedVirtualPortgroup.ConfigSpec()

        config.name = self.portgroup_name
        config.numPorts = self.num_ports

        # vim.VMwareDVSPortSetting() does not exist in the pyvmomi documentation
        # but this is the correct managed object type.

        config.defaultPortConfig = vim.VMwareDVSPortSetting()

        # vim.VmwareDistributedVirtualSwitchVlanIdSpec() does not exist in the
        # pyvmomi documentation but this is the correct managed object type
        if self.private:
            config.defaultPortConfig.vlan = vim.VmwareDistributedVirtualSwitchPvlanSpec(
            )
            config.defaultPortConfig.vlan.pvlanId = self.vlan_id
        else:
            config.defaultPortConfig.vlan = vim.VmwareDistributedVirtualSwitchVlanIdSpec(
            )
            config.defaultPortConfig.vlan.inherited = False
            config.defaultPortConfig.vlan.vlanId = self.vlan_id
        config.defaultPortConfig.securityPolicy = vim.dvs.VmwareDistributedVirtualSwitch.SecurityPolicy(
        )
        config.defaultPortConfig.securityPolicy.allowPromiscuous = vim.BoolPolicy(
            value=self.allow_promiscuous)
        config.defaultPortConfig.securityPolicy.forgedTransmits = vim.BoolPolicy(
            value=self.allow_forged_transmits)
        config.defaultPortConfig.securityPolicy.macChanges = vim.BoolPolicy(
            value=self.allow_mac_changes)
        config.type = self.portgroup_type

        spec = [config]
        task = self.dv_switch.AddDVPortgroup_Task(spec)
        changed, result = wait_for_task(task)
        return changed, result
Exemple #4
0
def port_setting():
    return vim.VMwareDVSPortSetting()