Search in sources :

Example 41 with SubnetState

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);
}
Also used : SubnetService(com.vmware.photon.controller.model.resources.SubnetService) ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) Operation(com.vmware.xenon.common.Operation) QueryTask(com.vmware.xenon.services.common.QueryTask) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ProvisionSubnetTaskService(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService) TestUtils(com.vmware.photon.controller.model.tasks.TestUtils) ServiceDocument(com.vmware.xenon.common.ServiceDocument) Test(org.junit.Test) VimNames(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames) NetworkService(com.vmware.photon.controller.model.resources.NetworkService) Query(com.vmware.xenon.services.common.QueryTask.Query) Ignore(org.junit.Ignore) DvsNetworkService(com.vmware.photon.controller.model.adapters.vsphere.network.DvsNetworkService) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) UriUtils(com.vmware.xenon.common.UriUtils) InstanceRequestType(com.vmware.photon.controller.model.adapterapi.SubnetInstanceRequest.InstanceRequestType) TaskOption(com.vmware.photon.controller.model.tasks.TaskOption) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) Assert(org.junit.Assert) EnumSet(java.util.EnumSet) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) NetworkState(com.vmware.photon.controller.model.resources.NetworkService.NetworkState) ProvisionSubnetTaskState(com.vmware.photon.controller.model.tasks.ProvisionSubnetTaskService.ProvisionSubnetTaskState) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 42 with SubnetState

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());
}
Also used : VirtualEthernetCardOpaqueNetworkBackingInfo(com.vmware.vim25.VirtualEthernetCardOpaqueNetworkBackingInfo) VirtualDeviceBackingInfo(com.vmware.vim25.VirtualDeviceBackingInfo) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 43 with SubnetState

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());
}
Also used : VirtualEthernetCardDistributedVirtualPortBackingInfo(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo) VirtualDeviceBackingInfo(com.vmware.vim25.VirtualDeviceBackingInfo) DistributedVirtualSwitchPortConnection(com.vmware.vim25.DistributedVirtualSwitchPortConnection) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 44 with SubnetState

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());
}
Also used : VirtualEthernetCardNetworkBackingInfo(com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) VirtualDeviceBackingInfo(com.vmware.vim25.VirtualDeviceBackingInfo) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Test(org.junit.Test)

Example 45 with SubnetState

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);
}
Also used : SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState)

Aggregations

SubnetState (com.vmware.photon.controller.model.resources.SubnetService.SubnetState)61 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)22 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)16 Operation (com.vmware.xenon.common.Operation)14 Query (com.vmware.xenon.services.common.QueryTask.Query)12 QueryUtils (com.vmware.photon.controller.model.query.QueryUtils)11 QueryByPages (com.vmware.photon.controller.model.query.QueryUtils.QueryByPages)11 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)11 URI (java.net.URI)11 DeferredResult (com.vmware.xenon.common.DeferredResult)10 HashMap (java.util.HashMap)10 List (java.util.List)10 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)9 StatelessService (com.vmware.xenon.common.StatelessService)9 SubnetService (com.vmware.photon.controller.model.resources.SubnetService)8 UriUtils (com.vmware.xenon.common.UriUtils)8 TagsUtil.newTagState (com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState)7 NetworkService (com.vmware.photon.controller.model.resources.NetworkService)7 TagState (com.vmware.photon.controller.model.resources.TagService.TagState)7