Java 类com.vmware.vim25.HostNetworkPolicy 实例源码

项目:cloudstack    文件:HostMO.java   
public void createPortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
        HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
    assert (portGroupName != null);
    HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
    assert (hostNetMo != null);

    HostPortGroupSpec spec = new HostPortGroupSpec();

    spec.setName(portGroupName);
    if (vlanId != null)
        spec.setVlanId(vlanId.intValue());
    HostNetworkPolicy policy = new HostNetworkPolicy();
    if (secPolicy != null)
        policy.setSecurity(secPolicy);
    policy.setShapingPolicy(shapingPolicy);
    spec.setPolicy(policy);
    spec.setVswitchName(vSwitch.getName());
    hostNetMo.addPortGroup(spec);
}
项目:cloudstack    文件:HostMO.java   
public void updatePortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
        HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
    assert (portGroupName != null);
    HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
    assert (hostNetMo != null);

    HostPortGroupSpec spec = new HostPortGroupSpec();

    spec.setName(portGroupName);
    if (vlanId != null)
        spec.setVlanId(vlanId.intValue());
    HostNetworkPolicy policy = new HostNetworkPolicy();
    if (secPolicy != null)
        policy.setSecurity(secPolicy);
    policy.setShapingPolicy(shapingPolicy);
    spec.setPolicy(policy);
    spec.setVswitchName(vSwitch.getName());
    hostNetMo.updatePortGroup(portGroupName, spec);
}