Bug 5904: Included version in API header

This commit is contained in:
kishan 2010-09-20 15:00:57 +05:30
parent 385f14e9ae
commit b606d14396
3 changed files with 23 additions and 13 deletions

View File

@ -2253,5 +2253,10 @@ public interface ManagementServer {
URISyntaxException, InternalErrorException;
long extractTemplateAsync(String url, Long templateId, Long zoneId) throws URISyntaxException;
long extractVolumeAsync(String url, Long volumeId, Long zoneId) throws URISyntaxException;
/*
* Fetches the version of cloud stack
*/
String getVersion();
}

View File

@ -624,13 +624,14 @@ public abstract class BaseCmd {
StringBuffer sb = new StringBuffer();
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
// JSON response
sb.append("{ \"" + getName() + "\" : { \"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
sb.append("{ \"" + getName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\""+getManagementServer().getVersion()+"\"},");
sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
} else {
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getName() + ">");
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
sb.append("</" + getName() + ">");
sb.append("</" + getName() + " cloud-stack-version=\""+getManagementServer().getVersion()+ "\">");
}
return sb.toString();
}
@ -640,10 +641,10 @@ public abstract class BaseCmd {
// set up the return value with the name of the response
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
sb.append("{ \"" + getName() + "\" : { ");
sb.append("{ \"" + getName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\""+getManagementServer().getVersion()+"\"},");
} else {
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
sb.append("<" + getName() + ">");
sb.append("<" + getName() + " cloud-stack-version=\""+getManagementServer().getVersion()+ "\">");
}
int i = 0;

View File

@ -8899,15 +8899,8 @@ public class ManagementServerImpl implements ManagementServer {
if(networkGroupsEnabled == null)
networkGroupsEnabled = "false";
capabilities.put("networkGroupsEnabled", networkGroupsEnabled);
final Class<?> c = this.getClass();
String fullVersion = c.getPackage().getImplementationVersion();
String version = "unknown";
if(fullVersion.length() > 0){
version = fullVersion.substring(0,fullVersion.lastIndexOf("."));
}
capabilities.put("cloudStackVersion", version);
capabilities.put("networkGroupsEnabled", networkGroupsEnabled);
capabilities.put("cloudStackVersion", getVersion());
return capabilities;
}
@ -9049,6 +9042,17 @@ public class ManagementServerImpl implements ManagementServer {
public List<VlanVO> searchForZoneWideVlans(long dcId, String vlanType, String vlanId){
return _vlanDao.searchForZoneWideVlans(dcId, vlanType, vlanId);
}
@Override
public String getVersion(){
final Class<?> c = this.getClass();
String fullVersion = c.getPackage().getImplementationVersion();
String version = "unknown";
if(fullVersion.length() > 0){
version = fullVersion.substring(0,fullVersion.lastIndexOf("."));
}
return version;
}
}