本文整理汇总了Java中org.onosproject.vtnrsc.floatingip.FloatingIpService类的典型用法代码示例。如果您正苦于以下问题:Java FloatingIpService类的具体用法?Java FloatingIpService怎么用?Java FloatingIpService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FloatingIpService类属于org.onosproject.vtnrsc.floatingip包,在下文中一共展示了FloatingIpService类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@Override
protected void execute() {
FloatingIpService service = get(FloatingIpService.class);
try {
FloatingIp floatingIpObj = new DefaultFloatingIp(
FloatingIpId.of(id),
TenantId.tenantId(tenantId),
TenantNetworkId.networkId(networkId),
VirtualPortId.portId(portId),
RouterId.valueOf(routerId),
floatingIp == null ? null : IpAddress.valueOf(floatingIp),
fixedIp == null ? null : IpAddress.valueOf(fixedIp),
status == null ? Status.ACTIVE
: Status.valueOf(status));
Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIpObj);
service.createFloatingIps(floatingIpSet);
} catch (Exception e) {
print(null, e.getMessage());
}
}
示例2: getFloatingIp
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@GET
@Path("{floatingIpUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getFloatingIp(@PathParam("floatingIpUUID") String id,
@QueryParam("fields") List<String> fields) {
if (!get(FloatingIpService.class).exists(FloatingIpId.of(id))) {
return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
}
FloatingIp sub = nullIsNotFound(get(FloatingIpService.class)
.getFloatingIp(FloatingIpId.of(id)), GET_FAIL);
ObjectNode result = new ObjectMapper().createObjectNode();
if (fields.size() > 0) {
result.set("floatingip",
new FloatingIpCodec().extracFields(sub, this, fields));
} else {
result.set("floatingip", new FloatingIpCodec().encode(sub, this));
}
return ok(result.toString()).build();
}
示例3: createFloatingIp
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response createFloatingIp(final InputStream input) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode subnode = mapper.readTree(input);
Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound((get(FloatingIpService.class)
.createFloatingIps(floatingIps)),
CREATE_FAIL);
if (!result) {
return Response.status(CONFLICT).entity(CREATE_FAIL).build();
}
return Response.status(CREATED).entity(result.toString()).build();
} catch (Exception e) {
return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
}
}
示例4: updateFloatingIp
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@PUT
@Path("{floatingIpUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response updateFloatingIp(@PathParam("floatingIpUUID") String id,
final InputStream input) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode subnode = mapper.readTree(input);
Collection<FloatingIp> floatingIps = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound(get(FloatingIpService.class)
.updateFloatingIps(floatingIps), UPDATE_FAIL);
if (!result) {
return Response.status(CONFLICT).entity(UPDATE_FAIL).build();
}
return ok(result.toString()).build();
} catch (Exception e) {
return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
}
}
示例5: deleteSingleFloatingIp
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@DELETE
@Path("{floatingIpUUID}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response deleteSingleFloatingIp(@PathParam("floatingIpUUID") String id)
throws IOException {
try {
FloatingIpId floatingIpId = FloatingIpId.of(id);
Set<FloatingIpId> floatingIpIds = Sets.newHashSet(floatingIpId);
Boolean result = nullIsNotFound(get(FloatingIpService.class)
.removeFloatingIps(floatingIpIds), DELETE_FAIL);
if (!result) {
return Response.status(CONFLICT).entity(DELETE_FAIL).build();
}
return Response.noContent().entity(DELETE_SUCCESS).build();
} catch (Exception e) {
return Response.status(NOT_FOUND).entity(e.getMessage()).build();
}
}
示例6: getFloatingIp
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@GET
@Path("{floatingIpUUID}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getFloatingIp(@PathParam("floatingIpUUID") String id,
@QueryParam("fields") List<String> fields) {
if (!get(FloatingIpService.class).exists(FloatingIpId.of(id))) {
return Response.status(NOT_FOUND).entity(NOT_EXIST).build();
}
FloatingIp sub = nullIsNotFound(get(FloatingIpService.class)
.getFloatingIp(FloatingIpId.of(id)), GET_FAIL);
ObjectNode result = new ObjectMapper().createObjectNode();
if (!fields.isEmpty()) {
result.set("floatingip",
new FloatingIpCodec().extracFields(sub, this, fields));
} else {
result.set("floatingip", new FloatingIpCodec().encode(sub, this));
}
return ok(result.toString()).build();
}
示例7: execute
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@Override
protected void execute() {
FloatingIpService service = get(FloatingIpService.class);
FloatingIpId floatingIpId = FloatingIpId.of(id);
FloatingIp floatingIpStore = get(FloatingIpService.class).getFloatingIp(floatingIpId);
try {
FloatingIp floatingIpObj = new DefaultFloatingIp(
floatingIpId,
tenantId == null ? floatingIpStore.tenantId()
: TenantId.tenantId(tenantId),
networkId == null ? floatingIpStore.networkId()
: TenantNetworkId.networkId(networkId),
portId == null ? floatingIpStore.portId()
: VirtualPortId.portId(portId),
routerId == null ? floatingIpStore.routerId()
: RouterId.valueOf(routerId),
floatingIp == null ? floatingIpStore.floatingIp()
: IpAddress.valueOf(floatingIp),
fixedIp == null ? floatingIpStore.fixedIp()
: IpAddress.valueOf(fixedIp),
status == null ? floatingIpStore.status()
: Status.valueOf(status));
Set<FloatingIp> floatingIpSet = Sets.newHashSet(floatingIpObj);
service.updateFloatingIps(floatingIpSet);
} catch (Exception e) {
print(null, e.getMessage());
}
}
示例8: listFloatingIps
import org.onosproject.vtnrsc.floatingip.FloatingIpService; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response listFloatingIps() {
Collection<FloatingIp> floatingIps = get(FloatingIpService.class)
.getFloatingIps();
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("floatingips",
new FloatingIpCodec().encode(floatingIps, this));
return ok(result.toString()).build();
}