private NetworkInterfaceState newNicStateFromDescription( ResourceAllocationTaskState state, NetworkInterfaceDescription nid) { NetworkInterfaceState nic = new NetworkInterfaceState(); nic.id = UUID.randomUUID().toString(); nic.documentSelfLink = nic.id; nic.name = nid.name; nic.deviceIndex = nid.deviceIndex; nic.address = nid.address; nic.networkLink = nid.networkLink; nic.subnetLink = nid.subnetLink; nic.networkInterfaceDescriptionLink = nid.documentSelfLink; nic.securityGroupLinks = nid.securityGroupLinks; nic.groupLinks = nid.groupLinks; nic.tagLinks = nid.tagLinks; nic.tenantLinks = state.tenantLinks; nic.endpointLink = nid.endpointLink; nic.endpointLinks = new HashSet<String>(); nic.endpointLinks.add(nid.endpointLink); nic.computeHostLink = nid.computeHostLink; nic.regionId = nid.regionId; nic.customProperties = nid.customProperties; return nic; }
private NetworkInterfaceState newNicStateFromDescription( ResourceAllocationTaskState state, NetworkInterfaceDescription nid) { NetworkInterfaceState nic = new NetworkInterfaceState(); nic.id = UUID.randomUUID().toString(); nic.documentSelfLink = nic.id; nic.name = nid.name; nic.deviceIndex = nid.deviceIndex; nic.address = nid.address; nic.networkLink = nid.networkLink; nic.subnetLink = nid.subnetLink; nic.networkInterfaceDescriptionLink = nid.documentSelfLink; nic.securityGroupLinks = nid.securityGroupLinks; nic.groupLinks = nid.groupLinks; nic.tagLinks = nid.tagLinks; nic.tenantLinks = state.tenantLinks; nic.endpointLink = nid.endpointLink; nic.regionId = nid.regionId; nic.customProperties = nid.customProperties; return nic; }
@Test public void testEvaluateSimpleBindingToObjectWithLinks() { List<Binding> bindings = Arrays .asList(binding(Arrays.asList("networks", "0", "address"), "_resource~A~parentLink")); Map<String, NestedState> computes = new HashMap<>(); TemplateComputeState computeStateA = new TemplateComputeState(); computeStateA.parentLink = "some-host"; computes.put("A", new NestedState(computeStateA)); TemplateComputeState computeState = new TemplateComputeState(); computeState.networkInterfaceLinks = Arrays.asList("nis-link"); NetworkInterfaceState nis = new NetworkInterfaceState(); nis.documentSelfLink = "nis-link"; NestedState nestedState = new NestedState(computeState); nestedState.children.put(nis.documentSelfLink, new NestedState(nis)); NestedState evalObj = BindingEvaluator .evaluateProvisioningTimeBindings(nestedState, bindings, computes); assertNotNull(evalObj); assertEquals(((NetworkInterfaceState) evalObj.children.get("nis-link").object).address, computeStateA.parentLink); }
@Test public void testEvaluateSimpleBindingFromObjectWithLinks() { List<Binding> bindings = Arrays .asList(binding(Arrays.asList("parentLink"), "_resource~A~networkInterfaceLinks~0~address")); Map<String, NestedState> computes = new HashMap<>(); TemplateComputeState computeStateA = new TemplateComputeState(); computeStateA.parentLink = "some-host"; computeStateA.networkInterfaceLinks = Arrays.asList("nis-link"); NetworkInterfaceState nis = new NetworkInterfaceState(); nis.documentSelfLink = "nis-link"; nis.address = "some-address"; NestedState nestedStateA = new NestedState(computeStateA); nestedStateA.children.put("nis-link", new NestedState(nis)); computes.put("A", nestedStateA); TemplateComputeState computeState = new TemplateComputeState(); NestedState nestedState = new NestedState(computeState); NestedState evalObj = BindingEvaluator .evaluateProvisioningTimeBindings(nestedState, bindings, computes); assertNotNull(evalObj); assertEquals(nis.address, ((TemplateComputeState) evalObj.object).parentLink); }
public static NetworkInterfaceStateWithDescription create( NetworkInterfaceDescription description, NetworkInterfaceState state) { NetworkInterfaceStateWithDescription stateWithDesc = new NetworkInterfaceStateWithDescription(); state.copyTo(stateWithDesc); // Populate 'stateWithDesc' from 'state' stateWithDesc.address = state.address; stateWithDesc.networkLink = state.networkLink; stateWithDesc.subnetLink = state.subnetLink; stateWithDesc.securityGroupLinks = state.securityGroupLinks; stateWithDesc.deviceIndex = state.deviceIndex; // Then extend with 'description' data stateWithDesc.networkInterfaceDescriptionLink = description.documentSelfLink; stateWithDesc.description = description; return stateWithDesc; }
public static NetworkInterfaceStateWithDescription create( NetworkInterfaceDescription description, NetworkInterfaceState state) { NetworkInterfaceStateWithDescription stateWithDesc = new NetworkInterfaceStateWithDescription(); state.copyTo(stateWithDesc); // Populate 'stateWithDesc' from 'state' stateWithDesc.address = state.address; stateWithDesc.networkLink = state.networkLink; stateWithDesc.subnetLink = state.subnetLink; stateWithDesc.securityGroupLinks = state.securityGroupLinks; stateWithDesc.deviceIndex = state.deviceIndex; // Then extend with 'description' data stateWithDesc.networkInterfaceDescriptionLink = description.documentSelfLink; stateWithDesc.description = description; return stateWithDesc; }
private static NetworkInterfaceState createNetworkInterface(BaseModelTest test) throws Throwable { NetworkInterfaceState networkInterfaceState = new NetworkInterfaceState(); networkInterfaceState.subnetLink = "subnetLink"; networkInterfaceState.name = UUID.randomUUID().toString(); networkInterfaceState.regionId = "regionId"; networkInterfaceState.id = UUID.randomUUID().toString(); return test.postServiceSynchronously(NetworkInterfaceService.FACTORY_LINK, networkInterfaceState, NetworkInterfaceState.class); }
public static Operation patchNicStateOperation(ServiceHost host, SubnetState subnet, String staticIp, String nicLink) { NetworkInterfaceState patch = new NetworkInterfaceState(); patch.networkLink = null; patch.subnetLink = subnet.documentSelfLink; patch.address = staticIp; return (Operation.createPatch(host, nicLink) .setBody(patch) .setReferer(host.getUri())); }