mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Fixed problems with inject checkin
This commit is contained in:
parent
54cce5fa18
commit
e936c32a04
@ -22,6 +22,7 @@ import java.util.List;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
@ -32,6 +33,8 @@ import com.cloud.dc.DataCenter;
|
||||
/**
|
||||
* Describes a zone and operations that can be done in a zone.
|
||||
*/
|
||||
@Path("/zone/{zoneid}")
|
||||
@Produces({"application/json"})
|
||||
@XmlRootElement(name="zone")
|
||||
public interface ZoneEntity extends DataCenterResourceEntity, DataCenter {
|
||||
@GET
|
||||
@ -40,4 +43,8 @@ public interface ZoneEntity extends DataCenterResourceEntity, DataCenter {
|
||||
|
||||
@Url(clazz=ProvisioningService.class, method="getPod", name="id", type=List.class)
|
||||
List<String> listPodIds();
|
||||
|
||||
@Override
|
||||
@Path("/enable")
|
||||
boolean enable();
|
||||
}
|
||||
|
||||
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.datacenter.entity.api;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
|
||||
|
||||
public class PodRestTO {
|
||||
|
||||
public String uuid;
|
||||
public String name;
|
||||
|
||||
public PodRestTO(PodEntity pod) {
|
||||
this.uuid = pod.getUuid();
|
||||
this.name = pod.getName();
|
||||
}
|
||||
|
||||
public PodRestTO() {
|
||||
}
|
||||
}
|
||||
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.datacenter.entity.api;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("zoneService")
|
||||
@Path("/zone/{zoneid}")
|
||||
public class ZoneRestTO {
|
||||
@Inject
|
||||
protected static ProvisioningService s_provisioningService;
|
||||
|
||||
|
||||
public String id;
|
||||
public URI uri;
|
||||
public String name;
|
||||
public URI[] pods;
|
||||
|
||||
public ZoneRestTO(UriInfo ui, ZoneEntity zone, URI uri) {
|
||||
this.id = zone.getUuid();
|
||||
this.name = zone.getName();
|
||||
this.uri = uri;
|
||||
List<String> podIds = zone.listPodIds();
|
||||
this.pods = new URI[podIds.size()];
|
||||
UriBuilder ub = ui.getAbsolutePathBuilder().path(this.getClass(), "getPod");
|
||||
Iterator<String> it = podIds.iterator();
|
||||
for (int i = 0; i < pods.length; i++) {
|
||||
String pod = it.next();
|
||||
pods[i] = ub.build(pod);
|
||||
}
|
||||
}
|
||||
|
||||
public ZoneRestTO() {
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/pods")
|
||||
public URI[] listPods(@PathParam("zoneid") String zoneId) {
|
||||
return this.pods;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/pod/{podid}")
|
||||
public PodRestTO getPod(@Context UriInfo ui, @PathParam("podid") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.datacenter.entity.api;
|
||||
|
||||
public class ZoneRestTOs {
|
||||
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Component
|
||||
@Service("ClusterRestService")
|
||||
@Produces("application/json")
|
||||
public class ClusterRestService {
|
||||
@Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/clusters")
|
||||
public List<ClusterEntity> listAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@GET @Path("/cluster/{clusterid}")
|
||||
public ClusterEntity get(@PathParam("clusterid") String clusterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/cluster/{clusterid}/enable")
|
||||
public String enable(@PathParam("clusterid") String clusterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/cluster/{clusterid}/disable")
|
||||
public String disable(@PathParam("clusterid") String clusterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/cluster/{clusterid}/deactivate")
|
||||
public String deactivate(@PathParam("clusterid") String clusterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/cluster/{clusterid}/reactivate")
|
||||
public String reactivate(@PathParam("clusterid") String clusterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PUT @Path("/cluster/create")
|
||||
public ClusterEntity create(
|
||||
@QueryParam("xid") String xid,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PUT @Path("/cluster/{clusterid}/update")
|
||||
public ClusterEntity update(
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("NetworkRestService")
|
||||
@Component
|
||||
@Produces("application/json")
|
||||
public class NetworkRestService {
|
||||
@PUT @Path("/network/create")
|
||||
public NetworkEntity create(
|
||||
@QueryParam("xid") String xid,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GET @Path("/network/{network-id}")
|
||||
public NetworkEntity get(@PathParam("network-id") String networkId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GET @Path("/networks")
|
||||
public List<NetworkEntity> listAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/network/{network-id}/")
|
||||
public String deploy(@PathParam("network-id") String networkId) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Component
|
||||
@Service("PodService")
|
||||
@Produces({"application/json"})
|
||||
public class PodRestService {
|
||||
@Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/pod/{pod-id}")
|
||||
public PodEntity getPod(@PathParam("pod-id") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/pod/{pod-id}/enable")
|
||||
public String enable(@PathParam("pod-id") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/pod/{pod-id}/disable")
|
||||
public String disable(@PathParam("pod-id") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/pod/{pod-id}/deactivate")
|
||||
public String deactivate(@PathParam("pod-id") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/pod/{pod-id}/reactivate")
|
||||
public String reactivate(@PathParam("pod-id") String podId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PUT @Path("/pod/create")
|
||||
public PodEntity create(
|
||||
@QueryParam("xid") String xid,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PUT @Path("/pod/{pod-id}")
|
||||
public PodEntity update(
|
||||
@PathParam("pod-id") String podId,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
||||
import org.apache.cloudstack.engine.rest.datacenter.entity.api.PodRestTO;
|
||||
import org.apache.cloudstack.engine.rest.datacenter.entity.api.ZoneRestTO;
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Path("/provisioning")
|
||||
@Produces({"application/xml", "application/json"})
|
||||
@Component
|
||||
public class ProvisioningRestService {
|
||||
@Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET
|
||||
@Path("/{zoneid}")
|
||||
public ZoneRestTO getZone(@Context UriInfo ui, @PathParam("zoneid") String id) {
|
||||
UriBuilder ub = ui.getAbsolutePathBuilder().path(this.getClass(), "getZone");
|
||||
ZoneEntity entity = _provisioningService.getZone(id);
|
||||
return new ZoneRestTO(ui, entity, ub.build(entity.getUuid()));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/zones")
|
||||
public ZoneRestTO[] listZones(@Context UriInfo ui) {
|
||||
List<ZoneEntity> zones = _provisioningService.listZones();
|
||||
ZoneRestTO[] tos = new ZoneRestTO[zones.size()];
|
||||
UriBuilder ub = ui.getAbsolutePathBuilder().path(this.getClass(), "getZone");
|
||||
Iterator<ZoneEntity> it = zones.iterator();
|
||||
for (int i = 0; i < tos.length; i++) {
|
||||
ZoneEntity entity = it.next();
|
||||
tos[i] = new ZoneRestTO(ui, entity, ub.build(entity.getUuid()));
|
||||
}
|
||||
return tos;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/zone/{zoneid}/pods")
|
||||
public PodRestTO[] listPods(@PathParam("zoneid") String zoneId) {
|
||||
List<PodEntity> pods = _provisioningService.listPods();
|
||||
PodRestTO[] tos = new PodRestTO[pods.size()];
|
||||
Iterator<PodEntity> it = pods.iterator();
|
||||
for (int i = 0; i < tos.length; i++) {
|
||||
PodEntity pod = it.next();
|
||||
tos[i] = new PodRestTO(pod);
|
||||
}
|
||||
return tos;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Component
|
||||
@Service("VirtualMachineRestService")
|
||||
@Produces("application/xml")
|
||||
public class VirtualMachineRestService {
|
||||
|
||||
@GET @Path("/vm/{vmid}")
|
||||
public VirtualMachineEntity get(@PathParam("vmid") String vmId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@PUT @Path("/vm/create")
|
||||
public VirtualMachineEntity create(
|
||||
@QueryParam("xid") String xid,
|
||||
@QueryParam("hostname") String hostname,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GET @Path("/vms")
|
||||
public List<VirtualMachineEntity> listAll() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Component
|
||||
@Service("VolumeRestService")
|
||||
@Produces("application/json")
|
||||
public class VolumeRestService {
|
||||
|
||||
@PUT @Path("/vol/create")
|
||||
public VolumeEntity create(
|
||||
@QueryParam("xid") String xid,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/vol/{volid}/deploy")
|
||||
public String deploy(@PathParam("volid") String volumeId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@GET @Path("/vols")
|
||||
public List<VolumeEntity> listAll() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/vol/{volid}/attach-to")
|
||||
public String attachTo(
|
||||
@PathParam("volid") String volumeId,
|
||||
@QueryParam("vmid") String vmId,
|
||||
@QueryParam("device-order") short device) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DELETE @Path("/vol/{volid}")
|
||||
public String delete(@PathParam("volid") String volumeId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/vol/{volid}/detach")
|
||||
public String detach(@QueryParam("volid") String volumeId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity;
|
||||
import org.apache.cloudstack.engine.service.api.ProvisioningService;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Component
|
||||
@Service("zoneService")
|
||||
@Produces({"application/json"})
|
||||
public class ZoneRestService {
|
||||
@Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/zones")
|
||||
public List<ZoneEntity> listAll() {
|
||||
return _provisioningService.listZones();
|
||||
}
|
||||
|
||||
@GET @Path("/zone/{zone-id}")
|
||||
public ZoneEntity get(@PathParam("zone-id") String zoneId) {
|
||||
return _provisioningService.getZone(zoneId);
|
||||
}
|
||||
|
||||
@POST @Path("/zone/{zone-id}/enable")
|
||||
public String enable(String zoneId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/zone/{zone-id}/disable")
|
||||
public String disable(@PathParam("zone-id") String zoneId) {
|
||||
ZoneEntity zoneEntity = _provisioningService.getZone(zoneId);
|
||||
zoneEntity.disable();
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/zone/{zone-id}/deactivate")
|
||||
public String deactivate(@PathParam("zone-id") String zoneId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@POST @Path("/zone/{zone-id}/activate")
|
||||
public String reactivate(@PathParam("zone-id") String zoneId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@PUT @Path("/zone/create")
|
||||
public ZoneEntity createZone(@QueryParam("xid") String xid,
|
||||
@QueryParam("display-name") String displayName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@DELETE @Path("/zone/{zone-id}")
|
||||
public String deleteZone(@QueryParam("zone-id") String xid) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -24,7 +24,10 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service("zoneService")
|
||||
public class ZoneEntityImpl implements ZoneEntity {
|
||||
String _id;
|
||||
String _name;
|
||||
|
||||
@ -10,12 +10,15 @@
|
||||
<import resource="classpath:META-INF/cxf/cxf.xml" />
|
||||
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
|
||||
|
||||
<context:component-scan base-package="org.apache.cloudstack" />
|
||||
<context:component-scan base-package="org.apache.cloudstack.engine.rest.service" />
|
||||
|
||||
<jaxrs:server id="restContainer" address="/">
|
||||
<jaxrs:server id="EngineService" address="/">
|
||||
<jaxrs:serviceBeans>
|
||||
<ref bean="provisioningService" />
|
||||
<ref bean="zoneService" />
|
||||
<ref bean="ZoneRestService" />
|
||||
<ref bean="PodRestService" />
|
||||
<ref bean="ClusterRestService" />
|
||||
<ref bean="VirtualMachineRestService" />
|
||||
<ref bean="VolumeRestService" />
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
|
||||
|
||||
@ -36,7 +36,6 @@ import com.cloud.dc.PodVlanVO;
|
||||
import com.cloud.org.Grouping;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -63,43 +62,44 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
protected SearchBuilder<DataCenterVO> ChildZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> DisabledZonesSearch;
|
||||
protected SearchBuilder<DataCenterVO> TokenSearch;
|
||||
|
||||
@Inject protected final DataCenterIpAddressDaoImpl _ipAllocDao;
|
||||
@Inject protected final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao;
|
||||
@Inject protected final DataCenterVnetDaoImpl _vnetAllocDao;
|
||||
@Inject protected final PodVlanDaoImpl _podVlanAllocDao;
|
||||
|
||||
@Inject protected DataCenterIpAddressDaoImpl _ipAllocDao = null;
|
||||
@Inject protected DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = null;
|
||||
@Inject protected DataCenterVnetDaoImpl _vnetAllocDao = null;
|
||||
@Inject protected PodVlanDaoImpl _podVlanAllocDao = null;
|
||||
@Inject protected DcDetailsDaoImpl _detailsDao = null;
|
||||
|
||||
protected long _prefix;
|
||||
protected Random _rand = new Random(System.currentTimeMillis());
|
||||
protected TableGenerator _tgMacAddress;
|
||||
|
||||
@Inject protected final DcDetailsDaoImpl _detailsDao;
|
||||
|
||||
|
||||
@Override
|
||||
public DataCenterVO findByName(String name) {
|
||||
SearchCriteria<DataCenterVO> sc = NameSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
SearchCriteria<DataCenterVO> sc = NameSearch.create();
|
||||
sc.setParameters("name", name);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DataCenterVO findByToken(String zoneToken){
|
||||
SearchCriteria<DataCenterVO> sc = TokenSearch.create();
|
||||
sc.setParameters("zoneToken", zoneToken);
|
||||
SearchCriteria<DataCenterVO> sc = TokenSearch.create();
|
||||
sc.setParameters("zoneToken", zoneToken);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> findZonesByDomainId(Long domainId){
|
||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||
sc.setParameters("domainId", domainId);
|
||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||
sc.setParameters("domainId", domainId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> findZonesByDomainId(Long domainId, String keyword){
|
||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||
sc.setParameters("domainId", domainId);
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> sc = ListZonesByDomainIdSearch.create();
|
||||
sc.setParameters("domainId", domainId);
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
@ -107,12 +107,12 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
}
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> findChildZones(Object[] ids, String keyword){
|
||||
SearchCriteria<DataCenterVO> sc = ChildZonesSearch.create();
|
||||
sc.setParameters("domainid", ids);
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> sc = ChildZonesSearch.create();
|
||||
sc.setParameters("domainid", ids);
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
@ -120,71 +120,71 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
}
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> listPublicZones(String keyword){
|
||||
SearchCriteria<DataCenterVO> sc = PublicZonesSearch.create();
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> sc = PublicZonesSearch.create();
|
||||
if (keyword != null) {
|
||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
sc.addAnd("name", SearchCriteria.Op.SC, ssc);
|
||||
}
|
||||
//sc.setParameters("domainId", domainId);
|
||||
//sc.setParameters("domainId", domainId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> findByKeyword(String keyword){
|
||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
SearchCriteria<DataCenterVO> ssc = createSearchCriteria();
|
||||
ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
|
||||
return listBy(ssc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releaseVnet(String vnet, long dcId, long physicalNetworkId, long accountId, String reservationId) {
|
||||
_vnetAllocDao.release(vnet, physicalNetworkId, accountId, reservationId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVnetVO> findVnet(long dcId, long physicalNetworkId, String vnet) {
|
||||
return _vnetAllocDao.findVnet(dcId, physicalNetworkId, vnet);
|
||||
return _vnetAllocDao.findVnet(dcId, physicalNetworkId, vnet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int countZoneVlans(long dcId, boolean onlyCountAllocated){
|
||||
return _vnetAllocDao.countZoneVlans(dcId, onlyCountAllocated);
|
||||
return _vnetAllocDao.countZoneVlans(dcId, onlyCountAllocated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releasePrivateIpAddress(String ipAddress, long dcId, Long instanceId) {
|
||||
_ipAllocDao.releaseIpAddress(ipAddress, dcId, instanceId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releasePrivateIpAddress(long nicId, String reservationId) {
|
||||
_ipAllocDao.releaseIpAddress(nicId, reservationId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releaseLinkLocalIpAddress(long nicId, String reservationId) {
|
||||
_LinkLocalIpAllocDao.releaseIpAddress(nicId, reservationId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void releaseLinkLocalIpAddress(String ipAddress, long dcId, Long instanceId) {
|
||||
_LinkLocalIpAllocDao.releaseIpAddress(ipAddress, dcId, instanceId);
|
||||
_LinkLocalIpAllocDao.releaseIpAddress(ipAddress, dcId, instanceId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deletePrivateIpAddressByPod(long podId) {
|
||||
return _ipAllocDao.deleteIpAddressByPod(podId);
|
||||
return _ipAllocDao.deleteIpAddressByPod(podId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean deleteLinkLocalIpAddressByPod(long podId) {
|
||||
return _LinkLocalIpAllocDao.deleteIpAddressByPod(podId);
|
||||
return _LinkLocalIpAllocDao.deleteIpAddressByPod(podId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +196,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
|
||||
return vo.getVnet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String allocatePodVlan(long podId, long accountId) {
|
||||
PodVlanVO vo = _podVlanAllocDao.take(podId, accountId);
|
||||
@ -214,7 +214,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
@Override
|
||||
public String[] getNextAvailableMacAddressPair(long id, long mask) {
|
||||
SequenceFetcher fetch = SequenceFetcher.getInstance();
|
||||
|
||||
|
||||
long seq = fetch.getNextSequence(Long.class, _tgMacAddress, id);
|
||||
seq = seq | _prefix | ((id & 0x7f) << 32);
|
||||
seq |= mask;
|
||||
@ -234,43 +234,44 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
return new Pair<String, Long>(vo.getIpAddress(), vo.getMacAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCenterIpAddressVO allocatePrivateIpAddress(long dcId, String reservationId) {
|
||||
DataCenterIpAddressVO vo = _ipAllocDao.takeDataCenterIpAddress(dcId, reservationId);
|
||||
return vo;
|
||||
DataCenterIpAddressVO vo = _ipAllocDao.takeDataCenterIpAddress(dcId, reservationId);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String allocateLinkLocalIpAddress(long dcId, long podId, long instanceId, String reservationId) {
|
||||
DataCenterLinkLocalIpAddressVO vo = _LinkLocalIpAllocDao.takeIpAddress(dcId, podId, instanceId, reservationId);
|
||||
DataCenterLinkLocalIpAddressVO vo = _LinkLocalIpAllocDao.takeIpAddress(dcId, podId, instanceId, reservationId);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
return vo.getIpAddress();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addVnet(long dcId, long physicalNetworkId, int start, int end) {
|
||||
_vnetAllocDao.add(dcId, physicalNetworkId, start, end);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteVnet(long physicalNetworkId) {
|
||||
_vnetAllocDao.delete(physicalNetworkId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVnetVO> listAllocatedVnets(long physicalNetworkId) {
|
||||
return _vnetAllocDao.listAllocatedVnets(physicalNetworkId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addPrivateIpAddress(long dcId,long podId, String start, String end) {
|
||||
_ipAllocDao.addIpRange(dcId, podId, start, end);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addLinkLocalIpAddress(long dcId,long podId, String start, String end) {
|
||||
_LinkLocalIpAllocDao.addIpRange(dcId, podId, start, end);
|
||||
_LinkLocalIpAllocDao.addIpRange(dcId, podId, start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -278,7 +279,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
if (!super.configure(name, params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
String value = (String)params.get("mac.address.prefix");
|
||||
_prefix = (long)NumbersUtil.parseInt(value, 06) << 40;
|
||||
|
||||
@ -291,33 +292,33 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected DataCenterDaoImpl() {
|
||||
super();
|
||||
NameSearch = createSearchBuilder();
|
||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
NameSearch.done();
|
||||
|
||||
|
||||
ListZonesByDomainIdSearch = createSearchBuilder();
|
||||
ListZonesByDomainIdSearch.and("domainId", ListZonesByDomainIdSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
|
||||
ListZonesByDomainIdSearch.done();
|
||||
|
||||
|
||||
PublicZonesSearch = createSearchBuilder();
|
||||
PublicZonesSearch.and("domainId", PublicZonesSearch.entity().getDomainId(), SearchCriteria.Op.NULL);
|
||||
PublicZonesSearch.done();
|
||||
|
||||
|
||||
ChildZonesSearch = createSearchBuilder();
|
||||
ChildZonesSearch.and("domainid", ChildZonesSearch.entity().getDomainId(), SearchCriteria.Op.IN);
|
||||
ChildZonesSearch.done();
|
||||
|
||||
|
||||
DisabledZonesSearch = createSearchBuilder();
|
||||
DisabledZonesSearch.and("allocationState", DisabledZonesSearch.entity().getAllocationState(), SearchCriteria.Op.EQ);
|
||||
DisabledZonesSearch.done();
|
||||
|
||||
|
||||
TokenSearch = createSearchBuilder();
|
||||
TokenSearch.and("zoneToken", TokenSearch.entity().getZoneToken(), SearchCriteria.Op.EQ);
|
||||
TokenSearch.done();
|
||||
|
||||
|
||||
_tgMacAddress = _tgs.get("macAddress");
|
||||
assert _tgMacAddress != null : "Couldn't get mac address table generator";
|
||||
}
|
||||
@ -334,7 +335,7 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
txn.commit();
|
||||
return persisted;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void loadDetails(DataCenterVO zone) {
|
||||
Map<String, String> details =_detailsDao.findDetails(zone.getId());
|
||||
@ -349,25 +350,25 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
}
|
||||
_detailsDao.persist(zone.getId(), details);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> listDisabledZones(){
|
||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
||||
sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
|
||||
|
||||
List<DataCenterVO> dcs = listBy(sc);
|
||||
|
||||
return dcs;
|
||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
||||
sc.setParameters("allocationState", Grouping.AllocationState.Disabled);
|
||||
|
||||
List<DataCenterVO> dcs = listBy(sc);
|
||||
|
||||
return dcs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataCenterVO> listEnabledZones(){
|
||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
||||
sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
|
||||
|
||||
List<DataCenterVO> dcs = listBy(sc);
|
||||
|
||||
return dcs;
|
||||
SearchCriteria<DataCenterVO> sc = DisabledZonesSearch.create();
|
||||
sc.setParameters("allocationState", Grouping.AllocationState.Enabled);
|
||||
|
||||
List<DataCenterVO> dcs = listBy(sc);
|
||||
|
||||
return dcs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -380,20 +381,20 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
|
||||
Long dcId = Long.parseLong(tokenOrIdOrName);
|
||||
return findById(dcId);
|
||||
} catch (NumberFormatException nfe) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean remove(Long id) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
DataCenterVO zone = createForUpdate();
|
||||
zone.setName(null);
|
||||
|
||||
|
||||
update(id, zone);
|
||||
|
||||
boolean result = super.remove(id);
|
||||
|
||||
@ -37,7 +37,6 @@ import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.api.Identity;
|
||||
import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
||||
@ -46,68 +45,68 @@ import com.cloud.utils.net.NetUtils;
|
||||
@Inheritance(strategy=InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name="purpose", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||
public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
@Inject protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao;
|
||||
|
||||
@Inject protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao = null;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
long id;
|
||||
|
||||
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
@Column(name=GenericDao.XID_COLUMN)
|
||||
String xId;
|
||||
|
||||
@Column(name="domain_id", updatable=false)
|
||||
long domainId;
|
||||
|
||||
|
||||
@Column(name="account_id", updatable=false)
|
||||
long accountId;
|
||||
|
||||
|
||||
@Column(name="ip_address_id", updatable=false)
|
||||
Long sourceIpAddressId;
|
||||
|
||||
|
||||
@Column(name="start_port", updatable=false)
|
||||
Integer sourcePortStart;
|
||||
|
||||
@Column(name="end_port", updatable=false)
|
||||
Integer sourcePortEnd;
|
||||
|
||||
|
||||
@Column(name="protocol", updatable=false)
|
||||
String protocol = NetUtils.TCP_PROTO;
|
||||
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="purpose")
|
||||
Purpose purpose;
|
||||
|
||||
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
@Column(name="state")
|
||||
State state;
|
||||
|
||||
|
||||
@Column(name=GenericDao.CREATED_COLUMN)
|
||||
Date created;
|
||||
|
||||
|
||||
@Column(name="network_id")
|
||||
long networkId;
|
||||
|
||||
|
||||
@Column(name="icmp_code")
|
||||
Integer icmpCode;
|
||||
|
||||
|
||||
@Column(name="icmp_type")
|
||||
Integer icmpType;
|
||||
|
||||
|
||||
|
||||
@Column(name="related")
|
||||
Long related;
|
||||
|
||||
|
||||
@Column(name="type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
FirewallRuleType type;
|
||||
|
||||
|
||||
@Column(name="traffic_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
TrafficType trafficType;
|
||||
|
||||
|
||||
|
||||
|
||||
// This is a delayed load value. If the value is null,
|
||||
// then this field has not been loaded yet.
|
||||
// Call firewallrules dao to load it.
|
||||
@ -168,7 +167,7 @@ public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
@ -177,29 +176,29 @@ public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
public Purpose getPurpose() {
|
||||
return purpose;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public long getNetworkId() {
|
||||
return networkId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FirewallRuleType getType() {
|
||||
return type;
|
||||
return type;
|
||||
}
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
|
||||
protected FirewallRuleVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
|
||||
public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol,
|
||||
long networkId, long accountId, long domainId, Purpose purpose, List<String> sourceCidrs, Integer icmpCode,
|
||||
Integer icmpType, Long related, TrafficType trafficType) {
|
||||
@ -209,11 +208,11 @@ public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
}
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
|
||||
|
||||
if (ipAddressId == null) {
|
||||
assert (purpose == Purpose.NetworkACL) : "ipAddressId can be null for " + Purpose.NetworkACL + " only";
|
||||
}
|
||||
|
||||
|
||||
this.sourceIpAddressId = ipAddressId;
|
||||
this.sourcePortStart = portStart;
|
||||
this.sourcePortEnd = portEnd;
|
||||
@ -224,28 +223,28 @@ public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
this.icmpCode = icmpCode;
|
||||
this.icmpType = icmpType;
|
||||
this.sourceCidrs = sourceCidrs;
|
||||
|
||||
|
||||
if (related != null) {
|
||||
assert (purpose == Purpose.Firewall) : "related field can be set for rule of purpose " + Purpose.Firewall + " only";
|
||||
}
|
||||
|
||||
|
||||
this.related = related;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.type = FirewallRuleType.User;
|
||||
this.trafficType = trafficType;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.type = FirewallRuleType.User;
|
||||
this.trafficType = trafficType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public FirewallRuleVO(String xId, long ipAddressId, int port, String protocol, long networkId, long accountId,
|
||||
long domainId, Purpose purpose, List<String> sourceCidrs, Integer icmpCode, Integer icmpType, Long related) {
|
||||
this(xId, ipAddressId, port, port, protocol, networkId, accountId, domainId, purpose, sourceCidrs, icmpCode, icmpType, related, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("Rule[").append(id).append("-").append(purpose).append("-").append(state).append("]").toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Integer getIcmpCode() {
|
||||
return icmpCode;
|
||||
@ -260,18 +259,18 @@ public class FirewallRuleVO implements Identity, FirewallRule {
|
||||
public Long getRelated() {
|
||||
return related;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setType(FirewallRuleType type) {
|
||||
this.type = type;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user