Search in sources :

Example 61 with SubnetState

use of com.vmware.photon.controller.model.resources.SubnetService.SubnetState in project photon-model by vmware.

the class AzureNetworkEnumerationAdapterService method buildSubnetState.

/**
 * Map Azure subnet to {@link SubnetState}.
 */
private SubnetState buildSubnetState(Subnet subnet, List<String> tenantLinks, String endpointLink, String location, String parentLink) {
    if (subnet == null) {
        throw new IllegalArgumentException("Cannot map Subnet to subnet state for null " + "instance.");
    }
    SubnetState subnetState = new SubnetState();
    subnetState.id = subnet.id;
    subnetState.name = subnet.name;
    if (subnet.properties != null) {
        subnetState.subnetCIDR = subnet.properties.addressPrefix;
    }
    subnetState.tenantLinks = tenantLinks;
    subnetState.endpointLink = endpointLink;
    AdapterUtils.addToEndpointLinks(subnetState, endpointLink);
    subnetState.supportPublicIpAddress = true;
    subnetState.computeHostLink = parentLink;
    subnetState.customProperties = new HashMap<>();
    subnetState.regionId = location;
    // on Azure, zoneId is the same as regionId
    subnetState.zoneId = location;
    if (AzureConstants.GATEWAY_SUBNET_NAME.equalsIgnoreCase(subnet.name)) {
        // This is a subnet gateway. Mark it for infrastructure use only.
        subnetState.customProperties.put(ComputeProperties.INFRASTRUCTURE_USE_PROP_NAME, Boolean.TRUE.toString());
    }
    return subnetState;
}
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