use of org.openstack4j.model.network.AttachInterfaceType in project camel by apache.
the class RouterProducer method doAttach.
private void doAttach(Exchange exchange) {
final Message msg = exchange.getIn();
final String routerId = msg.getHeader(NeutronConstants.ROUTER_ID, String.class);
final String subnetPortId = msg.getHeader(NeutronConstants.SUBNET_ID, msg.getHeader(NeutronConstants.PORT_ID), String.class);
final AttachInterfaceType type = msg.getHeader(NeutronConstants.ITERFACE_TYPE, AttachInterfaceType.class);
ObjectHelper.notEmpty(routerId, "Router ID");
ObjectHelper.notEmpty(subnetPortId, "Subnet/Port ID");
ObjectHelper.notNull(type, "AttachInterfaceType ");
RouterInterface routerInterface = os.networking().router().attachInterface(routerId, type, subnetPortId);
msg.setBody(routerInterface);
}
use of org.openstack4j.model.network.AttachInterfaceType in project camel by apache.
the class RouterProducerTest method attachTest.
@Test
public void attachTest() throws Exception {
final String routerID = "myRouterID";
final String subnetId = "subnet";
final RouterInterface ifce = new NeutronRouterInterface(subnetId, null);
when(routerService.attachInterface(anyString(), any(AttachInterfaceType.class), anyString())).thenReturn(ifce);
msg.setHeader(OpenstackConstants.OPERATION, NeutronConstants.ATTACH_INTERFACE);
msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
msg.setHeader(NeutronConstants.SUBNET_ID, subnetId);
msg.setHeader(NeutronConstants.ITERFACE_TYPE, AttachInterfaceType.SUBNET);
producer.process(exchange);
ArgumentCaptor<String> routerC = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<AttachInterfaceType> itfType = ArgumentCaptor.forClass(AttachInterfaceType.class);
ArgumentCaptor<String> subnetC = ArgumentCaptor.forClass(String.class);
verify(routerService).attachInterface(routerC.capture(), itfType.capture(), subnetC.capture());
assertEquals(routerID, routerC.getValue());
assertEquals(AttachInterfaceType.SUBNET, itfType.getValue());
assertEquals(subnetId, subnetC.getValue());
assertEquals(ifce, msg.getBody(RouterInterface.class));
}
Aggregations