Skip to content

Commit bd17d35

Browse files
author
Alex Huang
committed
Some initial checkins
1 parent 6866613 commit bd17d35

18 files changed

Lines changed: 1171 additions & 507 deletions

File tree

engine/api/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
<artifactId>cloud-api</artifactId>
3434
<version>${project.version}</version>
3535
</dependency>
36+
<dependency>
37+
<groupId>org.apache.cxf</groupId>
38+
<artifactId>cxf-bundle-jaxrs</artifactId>
39+
<version>2.7.0</version>
40+
<exclusions>
41+
<exclusion>
42+
<groupId>org.eclipse.jetty</groupId>
43+
<artifactId>jetty-server</artifactId>
44+
</exclusion>
45+
</exclusions>
46+
</dependency>
3647
</dependencies>
3748
<build>
3849
<defaultGoal>install</defaultGoal>

engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntity.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020

2121
import java.util.List;
2222

23+
import javax.ws.rs.BeanParam;
24+
import javax.ws.rs.GET;
25+
import javax.ws.rs.Path;
26+
import javax.ws.rs.Produces;
27+
import javax.xml.bind.annotation.XmlRootElement;
28+
2329
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
2430

2531
import com.cloud.deploy.DeployDestination;
@@ -31,12 +37,16 @@
3137
* Platform.
3238
*
3339
*/
40+
@Path("vm/{id}")
41+
@Produces({"application/json", "application/xml"})
42+
@XmlRootElement(name="vm")
3443
public interface VirtualMachineEntity extends VirtualMachine, CloudStackEntity {
3544

3645
/**
3746
* @return List of uuids for volumes attached to this virtual machine.
3847
*/
39-
List<String> listVolumeUuids();
48+
@GET
49+
List<String> listVolumeIds();
4050

4151
/**
4252
* @return List of volumes attached to this virtual machine.
@@ -74,7 +84,7 @@ public interface VirtualMachineEntity extends VirtualMachine, CloudStackEntity {
7484
* @param exclude list of areas to exclude
7585
* @return a reservation id
7686
*/
77-
String reserve(String plannerToUse, DeployDestination dest, ExcludeList exclude);
87+
String reserve(String plannerToUse, @BeanParam DeployDestination dest, ExcludeList exclude);
7888

7989
/**
8090
* Migrate this VM to a certain destination.

engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/DataCenterResourceEntity.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.apache.cloudstack.engine.datacenter.entity.api;
2020

21+
import javax.ws.rs.POST;
22+
2123
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
2224

2325
import com.cloud.utils.fsm.StateMachine2;
@@ -60,24 +62,29 @@ public enum Event {
6062
}
6163

6264
}
65+
6366
/**
6467
* Prepare the resource to take new on new demands.
6568
*/
69+
@POST
6670
boolean enable();
6771

6872
/**
6973
* Disables the resource. Cleanup. Prepare for the resource to be removed.
7074
*/
75+
@POST
7176
boolean disable();
7277

7378
/**
7479
* Do not use the resource for new demands.
7580
*/
81+
@POST
7682
boolean deactivate();
7783

7884
/**
7985
* Reactivates a deactivated resource.
8086
*/
87+
@POST
8188
boolean reactivate();
8289

8390
}

engine/api/src/org/apache/cloudstack/engine/datacenter/entity/api/ZoneEntity.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020

2121
import java.util.List;
2222

23+
import javax.ws.rs.GET;
24+
import javax.ws.rs.Path;
25+
2326
import com.cloud.dc.DataCenter;
2427

2528
/**
2629
* Describes a zone and operations that can be done in a zone.
2730
*/
31+
@Path("zone/{zone-id}")
2832
public interface ZoneEntity extends DataCenterResourceEntity, DataCenter {
29-
List<PodEntity> listPods();
33+
@GET
34+
List<PodEntity> listPods();
3035
}

engine/api/src/org/apache/cloudstack/engine/entity/api/CloudStackEntity.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import java.util.List;
2424
import java.util.Map;
2525

26+
import javax.ws.rs.GET;
27+
import javax.ws.rs.QueryParam;
28+
2629
/**
2730
* All entities returned by the Cloud Orchestration Platform must implement
2831
* this interface. CloudValueEntity is an immutable representation of
@@ -36,47 +39,49 @@ public interface CloudStackEntity {
3639
/**
3740
* @return the uuid of the object.
3841
*/
42+
@GET
3943
String getUuid();
4044

4145
/**
4246
* @return the id which is often the database id.
4347
*/
4448
long getId();
4549

46-
/**
47-
* @return external id set by the caller
48-
*/
49-
String getExternalId();
50-
5150
/**
5251
* @return current state for the entity
5352
*/
53+
@GET
5454
String getCurrentState();
5555

5656
/**
5757
* @return desired state for the entity
5858
*/
59+
@GET
5960
String getDesiredState();
6061

6162
/**
6263
* Get the time the entity was created
6364
*/
65+
@GET
6466
Date getCreatedTime();
6567

6668
/**
6769
* Get the time the entity was last updated
6870
*/
71+
@GET
6972
Date getLastUpdatedTime();
7073

7174
/**
7275
* @return reference to the owner of this entity
7376
*/
77+
@GET
7478
String getOwner();
7579

7680
/**
7781
* @return details stored for this entity when created.
7882
*/
79-
Map<String, String> getDetails(String source);
83+
Map<String, String> getDetails(
84+
@QueryParam("source") String source);
8085

8186
/**
8287
* @return a list of sources that have added to the details.

engine/api/src/org/apache/cloudstack/engine/service/api/EntityService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import java.util.List;
2222

23+
import javax.ws.rs.Path;
24+
2325
import com.cloud.network.Network;
2426
import com.cloud.storage.Volume;
2527
import com.cloud.vm.VirtualMachine;
@@ -28,6 +30,7 @@
2830
* Service to retrieve CloudStack entities
2931
* very likely to change
3032
*/
33+
@Path("resources")
3134
public interface EntityService {
3235
List<String> listVirtualMachines();
3336
List<String> listVolumes();

engine/api/src/org/apache/cloudstack/engine/service/api/OrchestrationService.java

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020

2121
import java.net.URL;
2222
import java.util.List;
23-
import java.util.Map;
23+
24+
import javax.ws.rs.DELETE;
25+
import javax.ws.rs.POST;
26+
import javax.ws.rs.Path;
27+
import javax.ws.rs.Produces;
28+
import javax.ws.rs.QueryParam;
2429

2530
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
2631
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
@@ -29,56 +34,68 @@
2934

3035
import com.cloud.hypervisor.Hypervisor;
3136

37+
@Path("orchestration")
38+
@Produces({"application/json", "application/xml"})
3239
public interface OrchestrationService {
3340
/**
3441
* creates a new virtual machine
3542
*
36-
* @param uuid externally unique name to reference the virtual machine
43+
* @param id externally unique name to reference the virtual machine
44+
* @param owner owner reference
3745
* @param template reference to the template
3846
* @param hostName name of the host
47+
* @param displayName name to look at
3948
* @param cpu # of cpu cores
40-
* @param speed speed of the cpu core
49+
* @param speed speed of the cpu core in MHZ
4150
* @param memory memory to allocate in bytes
42-
* @param networks networks that this VM belongs in
43-
* @param rootDiskTags tags for the root disk
4451
* @param computeTags tags for the compute
45-
* @param details extra details to store for the VM
46-
* @return VirtualMachine
52+
* @param rootDiskTags tags for the root disk
53+
* @param networks networks that this VM should join
54+
* @return VirtualMachineEntity
4755
*/
48-
VirtualMachineEntity createVirtualMachine(String name,
49-
String template,
50-
String hostName,
51-
int cpu,
52-
int speed,
53-
long memory,
54-
List<String> networks,
55-
List<String> rootDiskTags,
56-
List<String> computeTags,
57-
Map<String, String> details,
58-
String owner);
56+
@POST
57+
VirtualMachineEntity createVirtualMachine(
58+
@QueryParam("id") String id,
59+
@QueryParam("owner") String owner,
60+
@QueryParam("template-id") String templateId,
61+
@QueryParam("host-name") String hostName,
62+
@QueryParam("display-name") String displayName,
63+
@QueryParam("cpu") int cpu,
64+
@QueryParam("speed") int speed,
65+
@QueryParam("ram") long memory,
66+
@QueryParam("compute-tags") List<String> computeTags,
67+
@QueryParam("root-disk-tags") List<String> rootDiskTags,
68+
@QueryParam("networks") List<String> networks
69+
);
5970

60-
VirtualMachineEntity createVirtualMachineFromScratch(String uuid,
61-
String iso,
62-
String os,
63-
String hypervisor,
64-
String hostName,
65-
int cpu,
66-
int speed,
67-
long memory,
68-
List<String> networks,
69-
List<String> computeTags,
70-
Map<String, String> details,
71-
String owner);
71+
@POST
72+
VirtualMachineEntity createVirtualMachineFromScratch(
73+
@QueryParam("id") String id,
74+
@QueryParam("owner") String owner,
75+
@QueryParam("iso-id") String isoId,
76+
@QueryParam("host-name") String hostName,
77+
@QueryParam("display-name") String displayName,
78+
@QueryParam("hypervisor") String hypervisor,
79+
@QueryParam("os") String os,
80+
@QueryParam("cpu") int cpu,
81+
@QueryParam("speed") int speed,
82+
@QueryParam("ram") long memory,
83+
@QueryParam("compute-tags") List<String> computeTags,
84+
@QueryParam("root-disk-tags") List<String> rootDiskTags,
85+
@QueryParam("networks") List<String> networks);
7286

73-
NetworkEntity createNetwork(String externaId, String name, String cidr, String gateway);
87+
@POST
88+
NetworkEntity createNetwork(String id, String name, String domainName, String cidr, String gateway);
7489

90+
@DELETE
7591
void destroyNetwork(String networkUuid);
7692

93+
@POST
7794
VolumeEntity createVolume();
7895

96+
@DELETE
7997
void destroyVolume(String volumeEntity);
8098

99+
@POST
81100
TemplateEntity registerTemplate(String name, URL path, String os, Hypervisor hypervisor);
82-
83-
84101
}

engine/api/src/org/apache/cloudstack/engine/service/api/ProvisioningService.java

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24+
import javax.ws.rs.DELETE;
25+
import javax.ws.rs.GET;
26+
import javax.ws.rs.POST;
27+
import javax.ws.rs.Path;
28+
import javax.ws.rs.Produces;
29+
30+
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
31+
import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
32+
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
2433
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
2534

26-
import com.cloud.dc.DataCenter;
2735
import com.cloud.dc.Pod;
2836
import com.cloud.host.Host;
2937
import com.cloud.host.Status;
@@ -34,32 +42,56 @@
3442
* ProvisioningService registers and deregisters physical and virtual
3543
* resources that the management server can use.
3644
*/
45+
@Path("/provision")
46+
@Produces({"application/json", "application/xml"})
3747
public interface ProvisioningService {
3848

39-
String registerStorage(String name, List<String> tags, Map<String, String> details);
49+
@POST
50+
StorageEntity registerStorage(String name, List<String> tags, Map<String, String> details);
51+
52+
@POST
4053
ZoneEntity registerZone(String name, List<String> tags, Map<String, String> details);
41-
String registerPod(String name, List<String> tags, Map<String, String> details);
42-
String registerCluster(String name, List<String> tags, Map<String, String> details);
43-
String registerHost(String name, List<String> tags, Map<String, String> details);
4454

55+
@POST
56+
PodEntity registerPod(String name, List<String> tags, Map<String, String> details);
4557

58+
@POST
59+
ClusterEntity registerCluster(String name, List<String> tags, Map<String, String> details);
4660

61+
@POST
62+
String registerHost(String name, List<String> tags, Map<String, String> details);
63+
64+
@DELETE
4765
void deregisterStorage(String uuid);
66+
67+
@DELETE
4868
void deregisterZone();
69+
70+
@DELETE
4971
void deregisterPod();
72+
73+
@DELETE
5074
void deregisterCluster();
75+
76+
@DELETE
5177
void deregisterHost();
5278

5379
void changeState(String type, String entity, Status state);
5480

81+
@GET
82+
@Path("/hosts")
5583
List<Host> listHosts();
5684

85+
@GET
86+
@Path("/pods")
5787
List<Pod> listPods();
5888

59-
List<DataCenter> listZones();
60-
61-
89+
@GET
90+
@Path("/zones")
91+
List<ZoneEntity> listZones();
6292

93+
@GET
94+
@Path("/storages")
6395
List<StoragePool> listStorage();
6496

6597
}

0 commit comments

Comments
 (0)