Bug 12777 - Add storage network configuration into CloudStack

polish API per Alena's review
This commit is contained in:
frank 2012-01-09 11:06:21 -08:00
parent 391f3e8b30
commit 5ea56cdfeb
5 changed files with 13 additions and 14 deletions

View File

@ -28,7 +28,7 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@IdentityMapper(entityTableName="host_pod_ref")
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="UUID of pod where the ip range belongs to")
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="UUID of pod where the ip range belongs to")
private Long podId;
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, required=true, description="the beginning IP address")
@ -37,12 +37,8 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.END_IP, type=CommandType.STRING, description="the ending IP address")
private String endIp;
@Parameter(name=ApiConstants.VLAN, type=CommandType.INTEGER, description="Optional. the vlan the ip range sits on")
@Parameter(name = ApiConstants.VLAN, type = CommandType.INTEGER, description = "Optional. The vlan the ip range sits on, default to Null when it is not specificed which means you network is not on any Vlan. This is mainly for Vmware as other hypervisors can directly reterive bridge from pyhsical network traffic type table")
private Integer vlan;
@IdentityMapper(entityTableName="data_center")
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="The uuid of zone")
private Long zoneId;
@Parameter(name=ApiConstants.NETMASK, type=CommandType.STRING, required=true, description="the netmask for storage network")
private String netmask;
@ -66,11 +62,7 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
public Integer getVlan() {
return vlan;
}
public Long getZoneId() {
return zoneId;
}
public String getNetmask() {
return netmask;
}

View File

@ -49,6 +49,7 @@ public class ListTrafficTypeImplementorsCmd extends BaseListCmd {
TrafficTypeImplementorResponse p = new TrafficTypeImplementorResponse();
p.setTrafficType(r.first().toString());
p.setImplementor(r.second());
p.setObjectName("traffictypeimplementorresponse");
responses.add(p);
}

View File

@ -19,7 +19,7 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
@Implementation(description="Creates a Storage network IP range.", responseObject=UpdateStorageNetworkIpRangeCmd.class)
@Implementation(description="Update a Storage network IP range, only allowed when no IPs in this range have been allocated.", responseObject=UpdateStorageNetworkIpRangeCmd.class)
public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(UpdateStorageNetworkIpRangeCmd.class);
private static final String s_name = "updatestoragenetworkiprangeresponse";
@ -28,7 +28,7 @@ public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@IdentityMapper(entityTableName="dc_storage_network_ip_range")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="UUID of storage network ip range")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="UUID of storage network ip range")
private Long id;
@Parameter(name=ApiConstants.START_IP, type=CommandType.STRING, description="the beginning IP address")

View File

@ -3246,6 +3246,7 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setPodUuid(result.getPodUuid());
response.setZoneUuid(result.getZoneUuid());
response.setNetworkUuid(result.getNetworkUuid());
response.setObjectName("storagenetworkiprange");
return response;
}
}

View File

@ -185,7 +185,6 @@ public class StorageNetworkManagerImpl implements StorageNetworkManager, Storage
@Override
@DB
public StorageNetworkIpRange createIpRange(CreateStorageNetworkIpRangeCmd cmd) throws SQLException {
Long zoneId = cmd.getZoneId();
Long podId = cmd.getPodId();
String startIp = cmd.getStartIp();
String endIp = cmd.getEndIp();
@ -200,6 +199,12 @@ public class StorageNetworkManagerImpl implements StorageNetworkManager, Storage
throw new CloudRuntimeException("Invalid netmask:" + netmask);
}
HostPodVO pod = _podDao.findById(podId);
if (pod == null) {
throw new CloudRuntimeException("Cannot find pod " + podId);
}
Long zoneId = pod.getDataCenterId();
List<NetworkVO> nws = _networkDao.listByZoneAndTrafficType(zoneId, TrafficType.Storage);
if (nws.size() == 0) {
throw new CloudRuntimeException("Cannot find storage network in zone " + zoneId);