use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.
the class TestVSpherePortgroupProvisioning method createPortgroup.
@Test
public void createPortgroup() throws Throwable {
this.endpoint = createEndpoint(cs -> this.computeHost = cs, null);
// enumerate all resources hoping to find the template
doRefresh();
snapshotFactoryState("networks", NetworkService.class);
NetworkState dvsSwitch = fetchServiceState(NetworkState.class, findDvs(networkId));
SubnetState subnet = new SubnetState();
subnet.subnetCIDR = "0.0.0.0/0";
subnet.networkLink = dvsSwitch.documentSelfLink;
subnet.name = nextName("pg");
subnet.instanceAdapterReference = UriUtils.buildUri(this.host, DvsNetworkService.SELF_LINK);
subnet = TestUtils.doPost(this.host, subnet, SubnetState.class, UriUtils.buildUri(this.host, SubnetService.FACTORY_LINK));
ProvisionSubnetTaskState createTask = new ProvisionSubnetTaskState();
createTask.options = createOptions();
createTask.requestType = InstanceRequestType.CREATE;
createTask.subnetLink = subnet.documentSelfLink;
createTask = TestUtils.doPost(this.host, createTask, ProvisionSubnetTaskState.class, UriUtils.buildUri(this.host, ProvisionSubnetTaskService.FACTORY_LINK));
awaitTaskEnd(createTask);
// refresh state
subnet = getSubnetState(subnet);
// delete the portgroup
deleteThePortgroup(subnet);
}
use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.
the class NetworkDeviceBackingFactoryTest method testGetOpaqueNetworkBackingInfo.
@Test
public void testGetOpaqueNetworkBackingInfo() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(NsxProperties.OPAQUE_NET_ID, UUID.randomUUID().toString());
this.subnet.customProperties.put(NsxProperties.OPAQUE_NET_TYPE, UUID.randomUUID().toString());
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardOpaqueNetworkBackingInfo);
VirtualEthernetCardOpaqueNetworkBackingInfo opaqueNetworkBackingInfo = (VirtualEthernetCardOpaqueNetworkBackingInfo) deviceBackingInfo;
assertEquals(this.subnet.customProperties.get(NsxProperties.OPAQUE_NET_ID), opaqueNetworkBackingInfo.getOpaqueNetworkId());
assertEquals(this.subnet.customProperties.get(NsxProperties.OPAQUE_NET_TYPE), opaqueNetworkBackingInfo.getOpaqueNetworkType());
}
use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.
the class NetworkDeviceBackingFactoryTest method testGetDvsPortBackingInfoWithUUID.
@Test
public void testGetDvsPortBackingInfoWithUUID() {
this.subnet = new SubnetState();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(DvsProperties.DVS_UUID, UUID.randomUUID().toString());
this.subnet.customProperties.put(DvsProperties.PORT_GROUP_KEY, UUID.randomUUID().toString());
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardDistributedVirtualPortBackingInfo);
VirtualEthernetCardDistributedVirtualPortBackingInfo distributedVirtualPortBackingInfo = (VirtualEthernetCardDistributedVirtualPortBackingInfo) deviceBackingInfo;
DistributedVirtualSwitchPortConnection port = distributedVirtualPortBackingInfo.getPort();
assertNotNull(port);
assertEquals(this.subnet.customProperties.get(DvsProperties.DVS_UUID), port.getSwitchUuid());
assertEquals(this.subnet.customProperties.get(DvsProperties.PORT_GROUP_KEY), port.getPortgroupKey());
}
use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.
the class NetworkDeviceBackingFactoryTest method testStandardNetworkBackingInfo.
@Test
public void testStandardNetworkBackingInfo() {
this.subnet = new SubnetState();
this.subnet.name = UUID.randomUUID().toString();
this.subnet.customProperties = new HashMap<>();
this.subnet.customProperties.put(CustomProperties.TYPE, VimNames.TYPE_NETWORK);
VirtualDeviceBackingInfo deviceBackingInfo = NetworkDeviceBackingFactory.getNetworkDeviceBackingInfo(this.subnet);
assertTrue(deviceBackingInfo instanceof VirtualEthernetCardNetworkBackingInfo);
VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) deviceBackingInfo;
assertEquals(this.subnet.name, virtualEthernetCardNetworkBackingInfo.getDeviceName());
}
use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.
the class AzureLoadBalancerServiceTest method createSubnetState.
private SubnetState createSubnetState(String id) throws Throwable {
SubnetState subnetState = new SubnetState();
subnetState.id = id;
subnetState.name = this.subnetName;
subnetState.lifecycleState = LifecycleState.PROVISIONING;
subnetState.subnetCIDR = AZURE_NON_EXISTING_SUBNET_CIDR;
subnetState.networkLink = networkState.documentSelfLink;
subnetState.instanceAdapterReference = UriUtils.buildUri(this.host, AzureSubnetService.SELF_LINK);
subnetState.endpointLink = endpointState.documentSelfLink;
subnetState.tenantLinks = endpointState.tenantLinks;
return postServiceSynchronously(SubnetService.FACTORY_LINK, subnetState, SubnetState.class);
}
Aggregations