diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java index ca48b6fc4..a6fcd3a99 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java @@ -1,6 +1,5 @@ package com.woorea.openstack.nova.api; - import java.util.Map; import com.woorea.openstack.base.client.Entity; @@ -39,503 +38,458 @@ public class ServersResource { - private final OpenStackClient CLIENT; - - public ServersResource(OpenStackClient client) { - CLIENT = client; - } - - public List list(boolean detail) { - return new List(detail); - } - - public Boot boot(ServerForCreate server) { - return new Boot(server); - } - - public Show show(String id) { - return new Show(id); - } + private final OpenStackClient CLIENT; - public ShowMetadata showMetadata(String id) { - return new ShowMetadata(id); - } - - public CreateOrUpdateMetadata createOrUpdateMetadata(String id,Metadata metadata) { - return new CreateOrUpdateMetadata(id,metadata); - } - - public ReplaceMetadata replaceMetadata(String id,Metadata metadata) { - return new ReplaceMetadata(id,metadata); - } - public DeleteMetadata deleteMetadata(String id, String key) { - return new DeleteMetadata(id,key); - } + public ServersResource(OpenStackClient client) { + CLIENT = client; + } - public Delete delete(String id) { - return new Delete(id); - } + public List list(boolean detail) { + return new List(detail); + } - public class List extends OpenStackRequest { + public Boot boot(ServerForCreate server) { + return new Boot(server); + } - public List(boolean detail) { - super(CLIENT, HttpMethod.GET, detail ? "/servers/detail" : "/servers", null, Servers.class); - } + public Show show(String id) { + return new Show(id); + } - } + public ShowMetadata showMetadata(String id) { + return new ShowMetadata(id); + } - public class Boot extends OpenStackRequest { + public CreateOrUpdateMetadata createOrUpdateMetadata(String id, Metadata metadata) { + return new CreateOrUpdateMetadata(id, metadata); + } - private ServerForCreate server; + public ReplaceMetadata replaceMetadata(String id, Metadata metadata) { + return new ReplaceMetadata(id, metadata); + } - public Boot(ServerForCreate server) { - super(CLIENT, HttpMethod.POST, "/servers", Entity.json(server), Server.class); - this.server = server; - } + public DeleteMetadata deleteMetadata(String id, String key) { + return new DeleteMetadata(id, key); + } - } + public Delete delete(String id) { + return new Delete(id); + } - public class Show extends OpenStackRequest { + public class List extends OpenStackRequest { - public Show(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id), null, Server.class); - } + public List(boolean detail) { + super(CLIENT, HttpMethod.GET, detail ? "/servers/detail" : "/servers", null, Servers.class); + } + } - } + public class Boot extends OpenStackRequest { - public class ShowMetadata extends OpenStackRequest { + private ServerForCreate server; - public ShowMetadata(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id).append("/metadata"), null, Metadata.class); - } + public Boot(ServerForCreate server) { + super(CLIENT, HttpMethod.POST, "/servers", Entity.json(server), Server.class); + this.server = server; + } + } - } - - public class CreateOrUpdateMetadata extends OpenStackRequest { + public class Show extends OpenStackRequest { - public CreateOrUpdateMetadata(String id,Metadata metadata) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); - } + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id), null, Server.class); + } + } - } - public class ReplaceMetadata extends OpenStackRequest { + public class ShowMetadata extends OpenStackRequest { - public ReplaceMetadata(String id,Metadata metadata) { - super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); - } + public ShowMetadata(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id).append("/metadata"), null, Metadata.class); + } + } - } - - public class DeleteMetadata extends OpenStackRequest { + public class CreateOrUpdateMetadata extends OpenStackRequest { - public DeleteMetadata(String id,String key) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id).append("/metadata/").append(key), null, Void.class); - } + public CreateOrUpdateMetadata(String id, Metadata metadata) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); + } + } - } - - - public class Delete extends OpenStackRequest { + public class ReplaceMetadata extends OpenStackRequest { - public Delete(String id) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id), null, Void.class); - } + public ReplaceMetadata(String id, Metadata metadata) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); + } + } - } + public class DeleteMetadata extends OpenStackRequest { - public class ShowServerAddresses extends OpenStackRequest { + public DeleteMetadata(String id, String key) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id).append("/metadata/").append(key), null, Void.class); + } + } - public ShowServerAddresses(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id).append("/ips"), null, Addresses.class); - } + public class Delete extends OpenStackRequest { - } + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id), null, Void.class); + } + } - public class UpdateServer extends OpenStackRequest { + public class ShowServerAddresses extends OpenStackRequest { - private Server server; + public ShowServerAddresses(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id).append("/ips"), null, Addresses.class); + } + } - public UpdateServer(String id, Server server) { - super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id), Entity.json(server), Server.class); - this.server = server; - } + public class UpdateServer extends OpenStackRequest { - } - - public UpdateServer update(String serverId, String name, String accessIPv4, String accessIPv6) { - Server server = new Server(); - //server.setName(name); - //server.setAccessIPv4(accessIPv4); - //server.setAccessIPv6(accessIPv6); - return new UpdateServer(serverId, server); - } + private Server server; - public abstract class Action extends OpenStackRequest { + public UpdateServer(String id, Server server) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id), Entity.json(server), Server.class); + this.server = server; + } + } - public Action(String id, Entity entity, Class returnType) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), entity, returnType); - } + public UpdateServer update(String serverId, String name, String accessIPv4, String accessIPv6) { + Server server = new Server(); + //server.setName(name); + //server.setAccessIPv4(accessIPv4); + //server.setAccessIPv6(accessIPv6); + return new UpdateServer(serverId, server); + } - } + public abstract class Action extends OpenStackRequest { - public class ChangePasswordAction extends Action { + public Action(String id, Entity entity, Class returnType) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), entity, returnType); + } + } - private ChangePassword action; + public class ChangePasswordAction extends Action { - public ChangePasswordAction(String id, ChangePassword action) { - super(id, Entity.json(action), Server.class); - } + private ChangePassword action; - } - - public ChangePasswordAction changePassword(String serverId, String adminPass) { - ChangePassword changePassword = new ChangePassword(); - changePassword.setAdminPass(adminPass); - return new ChangePasswordAction(serverId, changePassword); - } + public ChangePasswordAction(String id, ChangePassword action) { + super(id, Entity.json(action), Server.class); + } + } - public class RebootAction extends Action { + public ChangePasswordAction changePassword(String serverId, String adminPass) { + ChangePassword changePassword = new ChangePassword(); + changePassword.setAdminPass(adminPass); + return new ChangePasswordAction(serverId, changePassword); + } - private Reboot action; + public class RebootAction extends Action { - public RebootAction(String id, Reboot action) { - super(id, Entity.json(action), Void.class); - } + private Reboot action; - } + public RebootAction(String id, Reboot action) { + super(id, Entity.json(action), Void.class); + } + } - public RebootAction reboot(String serverId, String rebootType) { - Reboot reboot = new Reboot(); - reboot.setType(rebootType); - return new RebootAction(serverId, reboot); - } + public RebootAction reboot(String serverId, String rebootType) { + Reboot reboot = new Reboot(); + reboot.setType(rebootType); + return new RebootAction(serverId, reboot); + } - public class RebuildAction extends Action { + public class RebuildAction extends Action { - private Rebuild action; + private Rebuild action; - public RebuildAction(String id, Rebuild action) { - super(id, Entity.json(action), Server.class); - } + public RebuildAction(String id, Rebuild action) { + super(id, Entity.json(action), Server.class); + } + } - } - - public RebuildAction rebuild(String serverId, Rebuild rebuild) { - return new RebuildAction(serverId, rebuild); - } + public RebuildAction rebuild(String serverId, Rebuild rebuild) { + return new RebuildAction(serverId, rebuild); + } - public class ResizeAction extends Action { + public class ResizeAction extends Action { - private Resize action; + private Resize action; - public ResizeAction(String id, Resize action) { - super(id, Entity.json(action), Server.class); - } + public ResizeAction(String id, Resize action) { + super(id, Entity.json(action), Server.class); + } + } - } - - public ResizeAction resize(String serverId, String flavorId, String diskConfig) { - Resize resize = new Resize(); - resize.setFlavorRef(flavorId); - resize.setDiskConfig(diskConfig); - return new ResizeAction(serverId, resize); - } + public ResizeAction resize(String serverId, String flavorId, String diskConfig) { + Resize resize = new Resize(); + resize.setFlavorRef(flavorId); + resize.setDiskConfig(diskConfig); + return new ResizeAction(serverId, resize); + } - public class ConfirmResizeAction extends Action { + public class ConfirmResizeAction extends Action { - public ConfirmResizeAction(String id) { - super(id, Entity.json(new ConfirmResize()), Server.class); - } + public ConfirmResizeAction(String id) { + super(id, Entity.json(new ConfirmResize()), Server.class); + } + } - } - - public ConfirmResizeAction confirmResize(String serverId) { - return new ConfirmResizeAction(serverId); - } + public ConfirmResizeAction confirmResize(String serverId) { + return new ConfirmResizeAction(serverId); + } - public class RevertResizeAction extends Action { + public class RevertResizeAction extends Action { - public RevertResizeAction(String id) { - super(id, Entity.json(new RevertResize()), Server.class); - } + public RevertResizeAction(String id) { + super(id, Entity.json(new RevertResize()), Server.class); + } + } - } - - public RevertResizeAction revertResize(String serverId) { - return new RevertResizeAction(serverId); - } + public RevertResizeAction revertResize(String serverId) { + return new RevertResizeAction(serverId); + } public class CreateImageAction extends Action { public CreateImageAction(String id, CreateImage createImage) { super(id, Entity.json(createImage), Void.class); } - } - + public CreateImageAction createImage(String serverId, String name, Map metadata) { - CreateImage createImage = new CreateImage(); - createImage.setName(name); - createImage.setMetadata(metadata); + CreateImage createImage = new CreateImage(name); + createImage.setMetadata(metadata); return new CreateImageAction(serverId, createImage); - } - - public class StartServer extends OpenStackRequest { - - private Start action; - - private String id; - - public StartServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Start()), Void.class); - } - - } - - public class StopServer extends OpenStackRequest { - - private Stop action; - - private String id; - - public StopServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Stop()), Void.class); - } - - } - - public StartServer start(String id) { - return new StartServer(id); - } - - public StopServer stop(String id) { - return new StopServer(id); - } - - public class GetVncConsoleServer extends OpenStackRequest { - - private GetVncConsole action; - - private String id; - - public GetVncConsoleServer(String id, GetVncConsole action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), VncConsole.class); - } - - } - - public GetVncConsoleServer getVncConsole(String id, String type) { - GetVncConsole action = new GetVncConsole(type); - return new GetVncConsoleServer(id, action); - } - - public class GetConsoleOutputServer extends OpenStackRequest { - - public GetConsoleOutputServer(String id, GetConsoleOutput action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), ConsoleOutput.class); - } - - } - - public GetConsoleOutputServer getConsoleOutput(String id, int length) { - GetConsoleOutput action = new GetConsoleOutput(length); - return new GetConsoleOutputServer(id, action); - } - - public class PauseServer extends OpenStackRequest { - - public PauseServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Pause()), Void.class); - } - - } - - public class UnpauseServer extends OpenStackRequest { + } - public UnpauseServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unpause()), Void.class); - } + public class StartServer extends OpenStackRequest { + private Start action; + private String id; - } + public StartServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Start()), Void.class); + } + } - public class LockServer extends OpenStackRequest { + public class StopServer extends OpenStackRequest { - private Lock action; + private Stop action; + private String id; - private String id; + public StopServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Stop()), Void.class); + } + } - public LockServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Lock()), Void.class); - } + public StartServer start(String id) { + return new StartServer(id); + } - } + public StopServer stop(String id) { + return new StopServer(id); + } - public class UnlockServer extends OpenStackRequest { + public class GetVncConsoleServer extends OpenStackRequest { - private Unlock action; + private GetVncConsole action; + private String id; - private String id; + public GetVncConsoleServer(String id, GetVncConsole action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), VncConsole.class); + } + } - public UnlockServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unlock()), Void.class); - } + public GetVncConsoleServer getVncConsole(String id, String type) { + GetVncConsole action = new GetVncConsole(type); + return new GetVncConsoleServer(id, action); + } - } + public class GetConsoleOutputServer extends OpenStackRequest { - public class SuspendServer extends OpenStackRequest { + public GetConsoleOutputServer(String id, GetConsoleOutput action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), ConsoleOutput.class); + } + } - public SuspendServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Suspend()), Void.class); - } + public GetConsoleOutputServer getConsoleOutput(String id, int length) { + GetConsoleOutput action = new GetConsoleOutput(length); + return new GetConsoleOutputServer(id, action); + } - } + public class PauseServer extends OpenStackRequest { - public class ResumeServer extends OpenStackRequest { + public PauseServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Pause()), Void.class); + } + } - public ResumeServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Resume()), Void.class); - } + public class UnpauseServer extends OpenStackRequest { - } + public UnpauseServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unpause()), Void.class); + } + } - public class CreateBackupServer extends OpenStackRequest { + public class LockServer extends OpenStackRequest { - public CreateBackupServer(String id, CreateBackup action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); - } + private Lock action; + private String id; - } + public LockServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Lock()), Void.class); + } + } - public PauseServer pause(String serverId) { - return new PauseServer(serverId); - } + public class UnlockServer extends OpenStackRequest { - public UnpauseServer unpause(String serverId) { - return new UnpauseServer(serverId); - } + private Unlock action; + private String id; - public LockServer lock(String serverId) { - return new LockServer(serverId); - } + public UnlockServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unlock()), Void.class); + } + } - public UnlockServer unlock(String serverId) { - return new UnlockServer(serverId); - } + public class SuspendServer extends OpenStackRequest { - public SuspendServer suspend(String serverId) { - return new SuspendServer(serverId); - } + public SuspendServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Suspend()), Void.class); + } + } - public ResumeServer resume(String serverId) { - return new ResumeServer(serverId); - } + public class ResumeServer extends OpenStackRequest { - public CreateBackupServer createBackup(String serverId, CreateBackup action) { - return new CreateBackupServer(serverId, action); - } + public ResumeServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Resume()), Void.class); + } + } - public class RescueServer extends OpenStackRequest { + public class CreateBackupServer extends OpenStackRequest { - public RescueServer(String id, Rescue action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); - } + public CreateBackupServer(String id, CreateBackup action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); + } + } - } + public PauseServer pause(String serverId) { + return new PauseServer(serverId); + } - public class UnrescueServer extends OpenStackRequest { + public UnpauseServer unpause(String serverId) { + return new UnpauseServer(serverId); + } - public UnrescueServer(String id) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unrescue()), Void.class); - } + public LockServer lock(String serverId) { + return new LockServer(serverId); + } - } + public UnlockServer unlock(String serverId) { + return new UnlockServer(serverId); + } - public RescueServer rescue(String serverId, String adminPass) { - Rescue action = new Rescue(adminPass); - return new RescueServer(serverId, action); - } + public SuspendServer suspend(String serverId) { + return new SuspendServer(serverId); + } - public UnrescueServer unrescue(String serverId) { - return new UnrescueServer(serverId); - } + public ResumeServer resume(String serverId) { + return new ResumeServer(serverId); + } - public class AssociateFloatingIp extends OpenStackRequest { + public CreateBackupServer createBackup(String serverId, CreateBackup action) { + return new CreateBackupServer(serverId, action); + } - public AssociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); - } + public class RescueServer extends OpenStackRequest { - } + public RescueServer(String id, Rescue action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); + } + } - public class DisassociateFloatingIp extends OpenStackRequest { + public class UnrescueServer extends OpenStackRequest { - public DisassociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); - } + public UnrescueServer(String id) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unrescue()), Void.class); + } + } - } + public RescueServer rescue(String serverId, String adminPass) { + Rescue action = new Rescue(adminPass); + return new RescueServer(serverId, action); + } - public AssociateFloatingIp associateFloatingIp(String serverId, String floatingIpAddress) { - com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp(floatingIpAddress); - return new AssociateFloatingIp(serverId, action); - } + public UnrescueServer unrescue(String serverId) { + return new UnrescueServer(serverId); + } - public DisassociateFloatingIp disassociateFloatingIp(String serverId, String floatingIpAddress) { - com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp(floatingIpAddress); - return new DisassociateFloatingIp(serverId, action); - } + public class AssociateFloatingIp extends OpenStackRequest { - public class AttachVolume extends OpenStackRequest { + public AssociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); + } + } - public AttachVolume(String serverId, final VolumeAttachment volumeAttachment) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), Entity.json(volumeAttachment), Void.class); - } + public class DisassociateFloatingIp extends OpenStackRequest { - } + public DisassociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); + } + } - public class DetachVolume extends OpenStackRequest { + public AssociateFloatingIp associateFloatingIp(String serverId, String floatingIpAddress) { + com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp(floatingIpAddress); + return new AssociateFloatingIp(serverId, action); + } - public DetachVolume(String serverId, String volumeId) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeId), null, Void.class); - } + public DisassociateFloatingIp disassociateFloatingIp(String serverId, String floatingIpAddress) { + com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp(floatingIpAddress); + return new DisassociateFloatingIp(serverId, action); + } - } + public class AttachVolume extends OpenStackRequest { - public class ListVolumeAttachments extends OpenStackRequest { + public AttachVolume(String serverId, final VolumeAttachment volumeAttachment) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), Entity.json(volumeAttachment), Void.class); + } + } - public ListVolumeAttachments(String serverId) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), null, VolumeAttachments.class); - } + public class DetachVolume extends OpenStackRequest { - } + public DetachVolume(String serverId, String volumeId) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeId), null, Void.class); + } + } - public class ShowVolumeAttachment extends OpenStackRequest { + public class ListVolumeAttachments extends OpenStackRequest { - public ShowVolumeAttachment(String serverId, String volumeAttachmentId) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeAttachmentId), null, VolumeAttachment.class); - } + public ListVolumeAttachments(String serverId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), null, VolumeAttachments.class); + } + } - } + public class ShowVolumeAttachment extends OpenStackRequest { - public AttachVolume attachVolume(String serverId, String volumeId, String device) { - VolumeAttachment volumeAttachment = new VolumeAttachment(); - volumeAttachment.setVolumeId(volumeId); - volumeAttachment.setDevice(device); - return new AttachVolume(serverId, volumeAttachment); - } + public ShowVolumeAttachment(String serverId, String volumeAttachmentId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeAttachmentId), null, VolumeAttachment.class); + } + } - public DetachVolume detachVolume(String serverId, String volumeId) { - return new DetachVolume(serverId, volumeId); - } + public AttachVolume attachVolume(String serverId, String volumeId, String device) { + VolumeAttachment volumeAttachment = new VolumeAttachment(); + volumeAttachment.setVolumeId(volumeId); + volumeAttachment.setDevice(device); + return new AttachVolume(serverId, volumeAttachment); + } - public ListVolumeAttachments listVolumeAttachments(String serverId) { - return new ListVolumeAttachments(serverId); - } + public DetachVolume detachVolume(String serverId, String volumeId) { + return new DetachVolume(serverId, volumeId); + } - public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) { - return new ShowVolumeAttachment(serverId, volumeAttachmentId); - } + public ListVolumeAttachments listVolumeAttachments(String serverId) { + return new ListVolumeAttachments(serverId); + } + public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) { + return new ShowVolumeAttachment(serverId, volumeAttachmentId); + } } - diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java index ec9c40f97..4e67d7701 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java @@ -1,51 +1,51 @@ package com.woorea.openstack.quantum; - import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackClientConnector; import com.woorea.openstack.quantum.api.NetworksResource; import com.woorea.openstack.quantum.api.PortsResource; import com.woorea.openstack.quantum.api.RoutersResource; +import com.woorea.openstack.quantum.api.SecurityGroupsResource; import com.woorea.openstack.quantum.api.SubnetsResource; - public class Quantum extends OpenStackClient { - - private final NetworksResource NETWORKS; - - private final PortsResource PORTS; - - private final SubnetsResource SUBNETS; - private final RoutersResource ROUTERS; - - public Quantum(String endpoint, OpenStackClientConnector connector) { - super(endpoint, connector); - NETWORKS = new NetworksResource(this); - PORTS = new PortsResource(this); - SUBNETS = new SubnetsResource(this); - ROUTERS=new RoutersResource(this); - - } - - public Quantum(String endpoint) { - this(endpoint, null); - } - - public NetworksResource networks() { - return NETWORKS; - } - - public PortsResource ports() { - return PORTS; - } - - public SubnetsResource subnets() { - return SUBNETS; - } - public RoutersResource routers() - { - return ROUTERS; - } - + private final NetworksResource NETWORKS; + private final PortsResource PORTS; + private final SubnetsResource SUBNETS; + private final RoutersResource ROUTERS; + private final SecurityGroupsResource SECURITYGROUPS; + + public Quantum(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + NETWORKS = new NetworksResource(this); + PORTS = new PortsResource(this); + SUBNETS = new SubnetsResource(this); + ROUTERS = new RoutersResource(this); + SECURITYGROUPS = new SecurityGroupsResource(this); + } + + public Quantum(String endpoint) { + this(endpoint, null); + } + + public NetworksResource networks() { + return NETWORKS; + } + + public PortsResource ports() { + return PORTS; + } + + public SubnetsResource subnets() { + return SUBNETS; + } + + public RoutersResource routers() { + return ROUTERS; + } + public SecurityGroupsResource securitygroups() { + return SECURITYGROUPS; + } + } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java index 97a919aba..dbd0b6e71 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java @@ -1,65 +1,64 @@ package com.woorea.openstack.quantum.api; - import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.quantum.model.Network; +import com.woorea.openstack.quantum.model.NetworkForCreate; import com.woorea.openstack.quantum.model.Networks; public class NetworksResource { - private final OpenStackClient CLIENT; + private final OpenStackClient CLIENT; - public NetworksResource(OpenStackClient client) { - CLIENT = client; - } + public NetworksResource(OpenStackClient client) { + CLIENT = client; + } - public List list() { - return new List(); - } + public List list() { + return new List(); + } - public Create create(Network net) { - return new Create(net); - } + public Create create(NetworkForCreate net) { + return new Create(net); + } public Update update(Network net) { return new Update(net); } - public Delete delete(String netId){ - return new Delete(netId); - } + public Delete delete(String netId) { + return new Delete(netId); + } - public Show show(String netId){ - return new Show(netId); - } + public Show show(String netId) { + return new Show(netId); + } - public class List extends OpenStackRequest { + public class List extends OpenStackRequest { - public List() { - super(CLIENT, HttpMethod.GET, "networks", null, Networks.class); - } - } + public List() { + super(CLIENT, HttpMethod.GET, "networks", null, Networks.class); + } + } - public class Query extends OpenStackRequest { + public class Query extends OpenStackRequest { - public Query(Network network) { - //super(network); + public Query(Network network) { + //super(network); // target = target.path("v2.0").path("networks"); // target = queryParam(target); // return target.request(MediaType.APPLICATION_JSON).get(Networks.class); - } - } - + } + } - public class Create extends OpenStackRequest { + public class Create extends OpenStackRequest { - public Create(Network net) { - super(CLIENT, HttpMethod.POST, "networks", Entity.json(net), Network.class); - } - } + public Create(NetworkForCreate net) { + super(CLIENT, HttpMethod.POST, "networks", Entity.json(net), Network.class); + } + } public class Update extends OpenStackRequest { @@ -68,17 +67,17 @@ public Update(Network net) { } } - public class Show extends OpenStackRequest { + public class Show extends OpenStackRequest { - public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("networks/", id), null, Network.class); - } - } + public Show(String id) { + super(CLIENT, HttpMethod.GET, buildPath("networks/", id), null, Network.class); + } + } - public class Delete extends OpenStackRequest { + public class Delete extends OpenStackRequest { - public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("networks/", id), null, Void.class); - } - } + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, buildPath("networks/", id), null, Void.class); + } + } } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java index bcd646d09..d3699834a 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java @@ -4,7 +4,9 @@ import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.quantum.model.ExternalGatewayForCreate; import com.woorea.openstack.quantum.model.Router; +import com.woorea.openstack.quantum.model.RouterExternalGateway; import com.woorea.openstack.quantum.model.RouterForAddInterface; import com.woorea.openstack.quantum.model.RouterForCreate; import com.woorea.openstack.quantum.model.RouterInterface; @@ -12,91 +14,100 @@ public class RoutersResource { - private final OpenStackClient CLIENT; + private final OpenStackClient CLIENT; - public RoutersResource(OpenStackClient client) { - CLIENT = client; - } + public RoutersResource(OpenStackClient client) { + CLIENT = client; + } - public List list() { - return new List(); - } + public List list() { + return new List(); + } - public Create create(RouterForCreate router){ - return new Create(router); - } + public Create create(RouterForCreate router) { + return new Create(router); + } - public Delete delete(String netId){ - return new Delete(netId); - } + public Delete delete(String netId) { + return new Delete(netId); + } - public Show show(String netId){ - return new Show(netId); - } + public Show show(String netId) { + return new Show(netId); + } - public class List extends OpenStackRequest { + public class List extends OpenStackRequest { - public List() { - super(CLIENT, HttpMethod.GET, "routers", null, Routers.class); - } - } + public List() { + super(CLIENT, HttpMethod.GET, "routers", null, Routers.class); + } + } - public class Query extends OpenStackRequest { + public class Query extends OpenStackRequest { - public Query(Router router) { - //super(network); + public Query(Router router) { + //super(network); // target = target.path("v2.0").path("networks"); // target = queryParam(target); // return target.request(MediaType.APPLICATION_JSON).get(Networks.class); - } - } - public class Create extends OpenStackRequest { + } + } - public Create(RouterForCreate router){ - super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class); - } - } + public class Create extends OpenStackRequest { - + public Create(RouterForCreate router) { + super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class); + } + } - public class Show extends OpenStackRequest { + public class Show extends OpenStackRequest { - public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class); - } - } + public Show(String id) { + super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class); + } + } - public class Delete extends OpenStackRequest { + public class Delete extends OpenStackRequest { - public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("routers/", id), null, Void.class); - } - } - public Attach addInterface(RouterForAddInterface interfaceToAdd){ - return new Attach(interfaceToAdd); - } - public class Attach extends OpenStackRequest { + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, buildPath("routers/", id), null, Void.class); + } + } - public Attach(RouterForAddInterface interfaceToAdd){ - super(CLIENT, HttpMethod.PUT, buildPath("routers/",interfaceToAdd.getRouterId(),"/add_router_interface"), Entity.json(interfaceToAdd),RouterInterface.class); - } - - } - public Detach deleteInterface(RouterForAddInterface interfaceRouter) { - return new Detach(interfaceRouter); - } + public Attach addInterface(RouterForAddInterface interfaceToAdd) { + return new Attach(interfaceToAdd); + } - public class Detach extends OpenStackRequest { + public class Attach extends OpenStackRequest { - public Detach(RouterForAddInterface interfaceToAdd) { - super(CLIENT, HttpMethod.PUT, buildPath("routers/", - interfaceToAdd.getRouterId(), "/remove_router_interface"), - Entity.json(interfaceToAdd), RouterInterface.class); - } + public Attach(RouterForAddInterface interfaceToAdd) { + super(CLIENT, HttpMethod.PUT, buildPath("routers/", interfaceToAdd.getRouterId(), "/add_router_interface"), Entity.json(interfaceToAdd), RouterInterface.class); + } + } - } + public Detach deleteInterface(RouterForAddInterface interfaceRouter) { + return new Detach(interfaceRouter); + } - - + public class Detach extends OpenStackRequest { + public Detach(RouterForAddInterface interfaceToAdd) { + super(CLIENT, HttpMethod.PUT, buildPath("routers/", + interfaceToAdd.getRouterId(), "/remove_router_interface"), + Entity.json(interfaceToAdd), RouterInterface.class); + } + } + + public SetExternalGateway setExternalGateway(ExternalGatewayForCreate externalGatewayForCreate) { + return new SetExternalGateway(externalGatewayForCreate); + } + + public class SetExternalGateway extends OpenStackRequest { + + public SetExternalGateway(ExternalGatewayForCreate externalGatewayForCreate) { + super(CLIENT, HttpMethod.PUT, buildPath("routers/", + externalGatewayForCreate.getRouterId()), + Entity.json(externalGatewayForCreate), RouterExternalGateway.class); + } + } } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SecurityGroupsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SecurityGroupsResource.java new file mode 100644 index 000000000..8200ff275 --- /dev/null +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SecurityGroupsResource.java @@ -0,0 +1,89 @@ +package com.woorea.openstack.quantum.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.quantum.model.SecurityGroup; +import com.woorea.openstack.quantum.model.SecurityGroupRule; +import com.woorea.openstack.quantum.model.SecurityGroups; + +/** + * Security Groups Management + * + * @author VAL Informatique + */ +public class SecurityGroupsResource { + + private final OpenStackClient CLIENT; + + public SecurityGroupsResource(OpenStackClient client) { + this.CLIENT = client; + } + + public List list() { + return new List(); + } + + public Create create(SecurityGroup securityGroup) { + return new Create(securityGroup); + } + + public Delete delete(String securityGroupId) { + return new Delete(securityGroupId); + } + + public Show show(String securityGroupId) { + return new Show(securityGroupId); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, "security-groups", null, SecurityGroups.class); + } + } + + public class Create extends OpenStackRequest { + + public Create(SecurityGroup securityGroup) { + super(CLIENT, HttpMethod.POST, "security-groups", Entity.json(securityGroup), SecurityGroup.class); + } + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, buildPath("security-groups/", id), null, SecurityGroup.class); + } + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, buildPath("security-groups/", id), null, Void.class); + } + } + + public AddRule addSecurityRule(SecurityGroupRule ruleToAdd) { + return new AddRule(ruleToAdd); + } + + public class AddRule extends OpenStackRequest { + + public AddRule(SecurityGroupRule ruleToAdd) { + super(CLIENT, HttpMethod.POST, "security-group-rules", Entity.json(ruleToAdd), SecurityGroupRule.class); + } + } + + public DeleteRule deleteSecurityRule(String id) { + return new DeleteRule(id); + } + + public class DeleteRule extends OpenStackRequest { + + public DeleteRule(String id) { + super(CLIENT, HttpMethod.DELETE, buildPath("security-group-rules/", id), null, Void.class); + } + } +} diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java index 1864604b2..02f83a4eb 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java @@ -1,65 +1,64 @@ package com.woorea.openstack.quantum.api; - import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.quantum.model.Subnet; +import com.woorea.openstack.quantum.model.SubnetForCreate; import com.woorea.openstack.quantum.model.Subnets; public class SubnetsResource { - private final OpenStackClient CLIENT; + private final OpenStackClient CLIENT; - public SubnetsResource(OpenStackClient client) { - CLIENT = client; - } + public SubnetsResource(OpenStackClient client) { + CLIENT = client; + } - public List list() { - return new List(); - } + public List list() { + return new List(); + } - public Create create(Subnet net) { - return new Create(net); - } + public Create create(SubnetForCreate net) { + return new Create(net); + } public Update update(Subnet net) { return new Update(net); } - public Delete delete(String netId){ - return new Delete(netId); - } + public Delete delete(String netId) { + return new Delete(netId); + } - public Show show(String netId){ - return new Show(netId); - } + public Show show(String netId) { + return new Show(netId); + } - public class List extends OpenStackRequest { + public class List extends OpenStackRequest { - public List() { - super(CLIENT, HttpMethod.GET, "subnets", null, Subnets.class); - } - } + public List() { + super(CLIENT, HttpMethod.GET, "subnets", null, Subnets.class); + } + } - public class Query extends OpenStackRequest { + public class Query extends OpenStackRequest { - public Query(Subnet subnet) { - //super(subnet); + public Query(Subnet subnet) { + //super(subnet); // target = target.path("v2.0").path("subnets"); // target = queryParam(target); // return target.request(MediaType.APPLICATION_JSON).get(Subnets.class); - } - } - + } + } - public class Create extends OpenStackRequest { + public class Create extends OpenStackRequest { - public Create(Subnet subnet) { - super(CLIENT, HttpMethod.POST, "subnets", Entity.json(subnet), Subnet.class); - } - } + public Create(SubnetForCreate subnet) { + super(CLIENT, HttpMethod.POST, "subnets", Entity.json(subnet), Subnet.class); + } + } public class Update extends OpenStackRequest { @@ -68,17 +67,17 @@ public Update(Subnet subnet) { } } - public class Show extends OpenStackRequest { + public class Show extends OpenStackRequest { - public Show(String id) { + public Show(String id) { super(CLIENT, HttpMethod.GET, buildPath("subnets/", id), null, Subnet.class); - } - } + } + } - public class Delete extends OpenStackRequest { + public class Delete extends OpenStackRequest { - public Delete(String id){ + public Delete(String id) { super(CLIENT, HttpMethod.DELETE, buildPath("subnets/", id), null, Void.class); - } - } + } + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/ExternalGatewayForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/ExternalGatewayForCreate.java new file mode 100644 index 000000000..c9c5f633f --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/ExternalGatewayForCreate.java @@ -0,0 +1,33 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; +import java.util.Map; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("router") +public class ExternalGatewayForCreate implements Serializable { + + @JsonProperty("external_gateway_info") + private Map external_gateway_info; + @JsonIgnore + String routerId; + + public Map getExternal_gateway_info() { + return external_gateway_info; + } + + public void setExternal_gateway_info( + Map external_gateway_info) { + this.external_gateway_info = external_gateway_info; + } + + public String getRouterId() { + return routerId; + } + + public void setRouterId(String routerId) { + this.routerId = routerId; + } +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java index 4490911e2..a30ad7f42 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java @@ -2,7 +2,6 @@ import java.io.Serializable; import java.util.List; - import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; @@ -14,31 +13,21 @@ public class Network implements Serializable { private String status; - private List subnets; - private String name; - @JsonProperty("admin_state_up") private Boolean adminStateUp; - @JsonProperty("tenant_id") private String tenantId; - @JsonProperty("provider:physical_network") private String providerPhysicalNetwork; - @JsonProperty("provider:network_type") private String providerNetworkType; - @JsonProperty("provider:segmentation_id") private Integer providerSegmentationId; - @JsonProperty("router:external") private String routerExternal; - private String id; - private String shared; /** @@ -50,8 +39,7 @@ public String getStatus() { } /** - * @param status - * the status to set + * @param status the status to set */ @JsonProperty public void setStatus(String status) { @@ -67,8 +55,7 @@ public List getSubnets() { } /** - * @param subnets - * the subnets to set + * @param subnets the subnets to set */ @JsonProperty public void setSubnets(List subnets) { @@ -83,8 +70,7 @@ public String getName() { } /** - * @param name - * the name to set + * @param name the name to set */ public void setName(String name) { this.name = name; @@ -101,8 +87,7 @@ public String getProviderPhyNet() { } /** - * @param providerPhyNet - * the providerPhyNet to set + * @param providerPhyNet the providerPhyNet to set * @deprecated */ @Deprecated @@ -124,8 +109,7 @@ public Boolean getAdminStateUp() { } /** - * @param adminStateUp - * the adminStateUp to set + * @param adminStateUp the adminStateUp to set */ public void setAdminStateUp(Boolean adminStateUp) { this.adminStateUp = adminStateUp; @@ -139,8 +123,7 @@ public String getTenantId() { } /** - * @param tenantId - * the tenantId to set + * @param tenantId the tenantId to set */ public void setTenantId(String tenantId) { this.tenantId = tenantId; @@ -157,8 +140,7 @@ public String getNetType() { } /** - * @param netType - * the netType to set + * @param netType the netType to set * @deprecated */ @Deprecated @@ -175,8 +157,7 @@ public String getRouterExternal() { } /** - * @param routerExternal - * the routerExternal to set + * @param routerExternal the routerExternal to set */ public void setRouterExternal(String routerExternal) { this.routerExternal = routerExternal; @@ -191,8 +172,7 @@ public String getId() { } /** - * @param id - * the id to set + * @param id the id to set */ @JsonProperty public void setId(String id) { @@ -207,8 +187,7 @@ public String getShared() { } /** - * @param shared - * the shared to set + * @param shared the shared to set */ public void setShared(String shared) { this.shared = shared; @@ -225,8 +204,7 @@ public String getProviderSegID() { } /** - * @param providerSegID - * the providerSegID to set + * @param providerSegID the providerSegID to set * @deprecated */ @Deprecated @@ -267,9 +245,9 @@ public void setProviderSegmentationId(Integer providerSegmentationId) { @Override public String toString() { return "Network [id=" + id + ", name=" + name + ", subnets=" - + subnets + ", status=" + status + ", admin_state_up=" + adminStateUp + ", tenant_id=" + - tenantId + ", shared=" + shared + ", provider:physical_network=" + providerPhysicalNetwork + - ", provider:network_type=" + providerNetworkType + ", router:external=" + routerExternal + - ", provider:segmentation_id=" + providerSegmentationId + "]"; + + subnets + ", status=" + status + ", admin_state_up=" + adminStateUp + ", tenant_id=" + + tenantId + ", shared=" + shared + ", provider:physical_network=" + providerPhysicalNetwork + + ", provider:network_type=" + providerNetworkType + ", router:external=" + routerExternal + + ", provider:segmentation_id=" + providerSegmentationId + "]"; } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java index 507e39b05..042bd012e 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java @@ -1,9 +1,81 @@ package com.woorea.openstack.quantum.model; +import java.io.Serializable; +import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonRootName; -@SuppressWarnings("serial") @JsonRootName("network") -@Deprecated -public class NetworkForCreate extends Network { +public class NetworkForCreate implements Serializable { + + private String name; + @JsonProperty("admin_state_up") + private boolean adminStateUp; + @JsonProperty("provider:network_type") + private String providerNetworkType; + @JsonProperty("provider:physical_network") + private String providerPhysicalNetwork; + @JsonProperty("provider:segmentation_id") + private Integer providerSegmentationId; + @JsonProperty("tenant_id") + private String tenantId; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the adminStateUp + */ + public boolean isAdminStateUp() { + return adminStateUp; + } + + /** + * @param adminStateUp the adminStateUp to set + */ + public void setAdminStateUp(boolean adminStateUp) { + this.adminStateUp = adminStateUp; + } + + public String getProviderNetworkType() { + return providerNetworkType; + } + + public void setProviderNetworkType(String providerNetworkType) { + this.providerNetworkType = providerNetworkType; + } + + public String getProviderPhysicalNetwork() { + return providerPhysicalNetwork; + } + + public void setProviderPhysicalNetwork(String providerPhysicalNetwork) { + this.providerPhysicalNetwork = providerPhysicalNetwork; + } + + public Integer getProviderSegmentationId() { + return providerSegmentationId; + } + + public void setProviderSegmentationId(Integer providerSegmentationId) { + this.providerSegmentationId = providerSegmentationId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java index e878b300f..793ef0bb6 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java @@ -2,7 +2,6 @@ import java.io.Serializable; import java.util.List; - import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; @@ -17,7 +16,6 @@ public static final class Ip implements Serializable { @JsonProperty("ip_address") private String address; - @JsonProperty("subnet_id") private String subnetId; @@ -29,8 +27,7 @@ public String getAddress() { } /** - * @param address - * the address to set + * @param address the address to set */ public void setAddress(String address) { this.address = address; @@ -44,8 +41,7 @@ public String getSubnetId() { } /** - * @param subnetId - * the subnetId to set + * @param subnetId the subnetId to set */ public void setSubnetId(String subnetId) { this.subnetId = subnetId; @@ -55,36 +51,24 @@ public void setSubnetId(String subnetId) { public String toString() { return "ip_addresses [ip_address=" + address + ", subnet_id=" + subnetId + "]"; } - } - @JsonProperty("admin_state_up") private Boolean adminStateUp; - @JsonProperty("device_id") private String deviceId; - @JsonProperty("device_owner") private String deviceOwner; - @JsonProperty("fixed_ips") private List list; - private String id; - @JsonProperty("mac_address") private String macAddress; - private String name; - @JsonProperty("network_id") private String networkId; - private String status; - @JsonProperty("tenant_id") private String tenantId; - @JsonProperty("security_groups") private List securityGroups; @@ -96,8 +80,7 @@ public Boolean getAdminStateUp() { } /** - * @param adminStateUp - * the adminStateUp to set + * @param adminStateUp the adminStateUp to set */ public void setAdminStateUp(Boolean adminStateUp) { this.adminStateUp = adminStateUp; @@ -111,8 +94,7 @@ public String getDeviceId() { } /** - * @param deviceId - * the deviceId to set + * @param deviceId the deviceId to set */ public void setDeviceId(String deviceId) { this.deviceId = deviceId; @@ -126,8 +108,7 @@ public String getDeviceOwner() { } /** - * @param deviceOwner - * the deviceOwner to set + * @param deviceOwner the deviceOwner to set */ public void setDeviceOwner(String deviceOwner) { this.deviceOwner = deviceOwner; @@ -141,8 +122,7 @@ public List getList() { } /** - * @param list - * the list to set + * @param list the list to set */ public void setList(List list) { this.list = list; @@ -157,8 +137,7 @@ public String getId() { } /** - * @param id - * the id to set + * @param id the id to set */ @JsonProperty public void setId(String id) { @@ -173,8 +152,7 @@ public String getMacAddress() { } /** - * @param macAddress - * the macAddress to set + * @param macAddress the macAddress to set */ public void setMacAddress(String macAddress) { this.macAddress = macAddress; @@ -188,8 +166,7 @@ public String getName() { } /** - * @param name - * the name to set + * @param name the name to set */ public void setName(String name) { this.name = name; @@ -203,8 +180,7 @@ public String getNetworkId() { } /** - * @param networkId - * the networkId to set + * @param networkId the networkId to set */ public void setNetworkId(String networkId) { this.networkId = networkId; @@ -219,8 +195,7 @@ public String getStatus() { } /** - * @param status - * the status to set + * @param status the status to set */ @JsonProperty public void setStatus(String status) { @@ -235,8 +210,7 @@ public String getTenantId() { } /** - * @param tenantId - * the tenantId to set + * @param tenantId the tenantId to set */ public void setTenantId(String tenantId) { this.tenantId = tenantId; @@ -250,8 +224,7 @@ public List getSecurityGroups() { } /** - * @param securityGroups - * IDs of security groups to associate to the port + * @param securityGroups IDs of security groups to associate to the port */ public void setSecurityGroups(List securityGroups) { this.securityGroups = securityGroups; diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java index 5f10d35dd..95a855d7f 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java @@ -3,7 +3,6 @@ import java.io.Serializable; import java.util.Iterator; import java.util.List; - import org.codehaus.jackson.annotate.JsonProperty; @SuppressWarnings("serial") @@ -20,8 +19,7 @@ public List getList() { } /** - * @param list - * the list to set + * @param list the list to set */ public void setList(List list) { this.list = list; @@ -36,5 +34,4 @@ public Iterator iterator() { public String toString() { return "Ports [list=" + list + "]"; } - } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterExternalGateway.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterExternalGateway.java new file mode 100644 index 000000000..18997ff08 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterExternalGateway.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.quantum.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +@JsonRootName("router") +public class RouterExternalGateway { + + @JsonProperty("external_gateway_info") + private Map external_gateway_info = new HashMap(); + + public Map getExternal_gateway_info() { + return external_gateway_info; + } + + public void setExternal_gateway_info(Map external_gateway_info) { + this.external_gateway_info = external_gateway_info; + } + @JsonProperty("status") + String status; + @JsonProperty("name") + String name; + @JsonProperty("admin_state_up") + String admin_state_up; + @JsonProperty("tenant_id") + String tenant_id; + @JsonProperty("id") + String id; + @JsonProperty("routes") + private List list; +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroup.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroup.java new file mode 100644 index 000000000..86caad8c5 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroup.java @@ -0,0 +1,65 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; +import java.util.List; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * Model for Security Group + * + * @author VAL Informatique + */ +@JsonRootName("security_group") +@JsonIgnoreProperties(ignoreUnknown = true) +public class SecurityGroup implements Serializable { + + private String description; + private String id; + private String name; + @JsonProperty("security_group_rules") + private List securityGroupRules; + @JsonProperty("tenant_id") + private String tenantId; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getSecurityGroupRules() { + return securityGroupRules; + } + + public void setSecurityGroupRules(List securityGroupRules) { + this.securityGroupRules = securityGroupRules; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroupRule.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroupRule.java new file mode 100644 index 000000000..327af0f57 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroupRule.java @@ -0,0 +1,116 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * Model for Security Group Rule + * + * @author VAL Informatique + */ +@JsonRootName("security_group_rule") +@JsonIgnoreProperties(ignoreUnknown = true) +public class SecurityGroupRule implements Serializable { + + private String direction; + private String ethertype; + private String id; + @JsonProperty("port_range_max") + private Integer portRangeMax; + @JsonProperty("port_range_min") + private Integer portRangeMin; + private String protocol; + @JsonProperty("remote_group_id") + private String remoteGroupId; + @JsonProperty("remote_ip_prefix") + private String remoteIpPrefix; + @JsonProperty("security_group_id") + private String securityGroupId; + @JsonProperty("tenant_id") + private String tenantId; + + public String getDirection() { + return direction; + } + + public void setDirection(String direction) { + this.direction = direction; + } + + public String getEthertype() { + return ethertype; + } + + public void setEthertype(String ethertype) { + this.ethertype = ethertype; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getPortRangeMax() { + return portRangeMax; + } + + public void setPortRangeMax(Integer portRangeMax) { + this.portRangeMax = portRangeMax; + } + + public Integer getPortRangeMin() { + return portRangeMin; + } + + public void setPortRangeMin(Integer portRangeMin) { + this.portRangeMin = portRangeMin; + } + + public String getProtocol() { + return protocol; + } + + public void setProtocol(String protocol) { + this.protocol = protocol; + } + + public String getRemoteGroupId() { + return remoteGroupId; + } + + public void setRemoteGroupId(String remoteGroupId) { + this.remoteGroupId = remoteGroupId; + } + + public String getRemoteIpPrefix() { + return remoteIpPrefix; + } + + public void setRemoteIpPrefix(String remoteIpPrefix) { + this.remoteIpPrefix = remoteIpPrefix; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + + +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroups.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroups.java new file mode 100644 index 000000000..ac2795b9c --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SecurityGroups.java @@ -0,0 +1,41 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Model for Security Groups + * + * @author VAL Informatique + */ +public class SecurityGroups implements Iterable, Serializable { + + @JsonProperty("security_groups") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /** + * @param list the list to set + */ + public void setList(List list) { + this.list = list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Security groups [list=" + list + "]"; + } +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java index 73015146b..bac0b045d 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java @@ -2,12 +2,8 @@ import java.io.Serializable; import java.util.List; - -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonIgnore; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonValue; import org.codehaus.jackson.map.annotate.JsonRootName; @SuppressWarnings("serial") @@ -16,50 +12,38 @@ public class Subnet implements Serializable { private String name; - @JsonProperty("enable_dhcp") - private Boolean enableDHCP; - + private boolean enableDHCP; @JsonProperty("network_id") private String networkId; - @JsonProperty("tenant_id") private String tenantId; - @JsonProperty("dns_nameservers") private List dnsNames; - @JsonProperty("allocation_pools") private List list; - @JsonProperty("host_routes") private List hostRoutes; - @JsonProperty("ip_version") - private IpVersion ipversion; - + private int ipversion; @JsonProperty("gateway_ip") private String gw; - private String cidr; - private String id; public static enum IpVersion implements Serializable { - IPV4(4), - IPV6(6); + + IPV4(4), IPV6(6); private int code; IpVersion(int code) { this.code = code; } - @JsonValue public int code() { return code; } - @JsonCreator public static IpVersion valueOf(int value) { for (IpVersion ipVersion : IpVersion.values()) { if (ipVersion.code() == value) { @@ -83,8 +67,7 @@ public String getName() { } /** - * @param name - * the name to set + * @param name the name to set */ public void setName(String name) { this.name = name; @@ -93,20 +76,21 @@ public void setName(String name) { /** * @return the enableDHCP */ - @JsonIgnore public boolean isEnableDHCP() { return enableDHCP; } + /** + * @return the enableDHCP + */ public Boolean getEnableDHCP() { return enableDHCP; } /** - * @param enableDHCP - * the enableDHCP to set + * @param enableDHCP the enableDHCP to set */ - public void setEnableDHCP(Boolean enableDHCP) { + public void setEnableDHCP(boolean enableDHCP) { this.enableDHCP = enableDHCP; } @@ -118,8 +102,7 @@ public String getNetworkId() { } /** - * @param networkId - * the networkId to set + * @param networkId the networkId to set */ public void setNetworkId(String networkId) { this.networkId = networkId; @@ -133,8 +116,7 @@ public String getTenantId() { } /** - * @param tenantId - * the tenantId to set + * @param tenantId the tenantId to set */ public void setTenantId(String tenantId) { this.tenantId = tenantId; @@ -148,8 +130,7 @@ public List getDnsNames() { } /** - * @param dnsNames - * the dnsNames to set + * @param dnsNames the dnsNames to set */ public void setDnsNames(List dnsNames) { this.dnsNames = dnsNames; @@ -163,8 +144,7 @@ public List getList() { } /** - * @param list - * the list to set + * @param list the list to set */ public void setList(List list) { this.list = list; @@ -178,8 +158,7 @@ public List getHostRoutes() { } /** - * @param hostRoutes - * the hostRoutes to set + * @param hostRoutes the hostRoutes to set */ public void setHostRoutes(List hostRoutes) { this.hostRoutes = hostRoutes; @@ -188,15 +167,14 @@ public void setHostRoutes(List hostRoutes) { /** * @return the ipversion */ - public IpVersion getIpversion() { + public int getIpversion() { return ipversion; } /** - * @param ipversion - * the ipversion to set + * @param ipversion the ipversion to set */ - public void setIpversion(IpVersion ipversion) { + public void setIpversion(int ipversion) { this.ipversion = ipversion; } @@ -208,8 +186,7 @@ public String getGw() { } /** - * @param gw - * the gw to set + * @param gw the gw to set */ public void setGw(String gw) { this.gw = gw; @@ -223,8 +200,7 @@ public String getCidr() { } /** - * @param cidr - * the cidr to set + * @param cidr the cidr to set */ public void setCidr(String cidr) { this.cidr = cidr; @@ -233,23 +209,19 @@ public void setCidr(String cidr) { /** * @return the id */ - @JsonIgnore public String getId() { return id; } /** - * @param id - * the id to set + * @param id the id to set */ - @JsonProperty public void setId(String id) { this.id = id; } - /* - * (non-Javadoc) - * + + /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override @@ -260,5 +232,4 @@ public String toString() { + ", cidr=" + cidr + ", enable_dhcp=" + enableDHCP + ", dns_nameservers=" + dnsNames + ", host_routes=" + hostRoutes + "]"; } - } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java index 2c07ab255..a1b27f92a 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java @@ -1,34 +1,105 @@ package com.woorea.openstack.quantum.model; -import org.codehaus.jackson.annotate.JsonIgnore; +import java.io.Serializable; +import java.util.List; +import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.annotate.JsonRootName; -/** - * Please use {@link Subnet} directly. - */ -@SuppressWarnings("serial") @JsonRootName("subnet") -@Deprecated -public class SubnetForCreate extends Subnet { +public class SubnetForCreate implements Serializable { + + private String name; + @JsonProperty("network_id") + private String networkId; + @JsonProperty("ip_version") + private int ipVersion; + private String cidr; + @JsonProperty("allocation_pools") + private List list; + @JsonProperty("tenant_id") + private String tenantId; + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the id + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param id the id to set + */ + public void setNetworkId(String id) { + this.networkId = id; + } /** * @return the ipVersion - * @deprecated */ - @Deprecated - @JsonIgnore public int getIpVersion() { - return getIpversion().code(); + return ipVersion; } /** - * @param ipVersion - * the ipVersion to set - * @deprecated + * @param ipVersion the ipVersion to set */ - @Deprecated - @JsonIgnore public void setIpVersion(int ipVersion) { - setIpversion(IpVersion.valueOf(ipVersion)); + this.ipVersion = ipVersion; + } + + /** + * @return the cidr + */ + public String getCidr() { + return cidr; + } + + /** + * @param cidr the cidr to set + */ + public void setCidr(String cidr) { + this.cidr = cidr; + } + + /** + * @return the list + */ + public List getList() { + return list; + } + + /** + * @param list the list to set + */ + public void setList(List list) { + this.list = list; + } + + /** + * @return the tenantId + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId the tenantId to set + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; } } diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java index 9136a38cc..cba6ef371 100644 --- a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java @@ -67,7 +67,7 @@ public void testSerialization() throws Exception { subnet.setCidr(CIDR); subnet.setDnsNames(Arrays.asList(DNS_SERVER)); subnet.setEnableDHCP(ENABLE_DHCP); - subnet.setIpversion(IP_VERSION); + subnet.setIpversion(IP_VERSION.code()); subnet.setGw(GATEWAY); subnet.setHostRoutes(Arrays.asList(HOST_ROUTE)); subnet.setName(NAME); @@ -117,7 +117,7 @@ public void testDeserializationAfterSerialization() throws Exception { assertThat(subnet.getCidr(), is(equalTo(CIDR))); assertThat(subnet.getDnsNames(), hasItem(equalTo(DNS_SERVER))); assertThat(subnet.isEnableDHCP(), is(equalTo(ENABLE_DHCP))); - assertThat(subnet.getIpversion(), is(equalTo(IP_VERSION))); + assertThat(subnet.getIpversion(), is(equalTo(IP_VERSION.code()))); assertThat(subnet.getGw(), is(equalTo(GATEWAY))); assertThat(subnet.getHostRoutes(), hasItem(equalTo(HOST_ROUTE))); assertThat(subnet.getName(), is(equalTo(NAME)));