mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
52f68a273a
@ -729,7 +729,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
_shell.setPersistentProperty(null, KeyStoreUtils.KS_PASSPHRASE_PROPERTY, storedPassword);
|
||||
}
|
||||
|
||||
Script script = new Script(_keystoreSetupPath, 60000, s_logger);
|
||||
Script script = new Script(_keystoreSetupPath, 300000, s_logger);
|
||||
script.add(agentFile.getAbsolutePath());
|
||||
script.add(keyStoreFile);
|
||||
script.add(storedPassword);
|
||||
@ -773,7 +773,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
throw new CloudRuntimeException("Unable to save received agent client and ca certificates", e);
|
||||
}
|
||||
|
||||
Script script = new Script(_keystoreCertImportPath, 60000, s_logger);
|
||||
Script script = new Script(_keystoreCertImportPath, 300000, s_logger);
|
||||
script.add(agentFile.getAbsolutePath());
|
||||
script.add(keyStoreFile);
|
||||
script.add(KeyStoreUtils.AGENT_MODE);
|
||||
|
||||
@ -164,7 +164,7 @@ public class VirtualRoutingResource {
|
||||
cmd.getKeystorePassword(),
|
||||
cmd.getValidityDays(),
|
||||
KeyStoreUtils.CSR_FILENAME);
|
||||
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), KeyStoreUtils.KS_SETUP_SCRIPT, args);
|
||||
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), KeyStoreUtils.KS_SETUP_SCRIPT, args, Duration.standardMinutes(15));
|
||||
return new SetupKeystoreAnswer(result.getDetails());
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public class VirtualRoutingResource {
|
||||
cmd.getEncodedCaCertificates(),
|
||||
KeyStoreUtils.PKEY_FILENAME,
|
||||
cmd.getEncodedPrivateKey());
|
||||
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), KeyStoreUtils.KS_IMPORT_SCRIPT, args);
|
||||
ExecutionResult result = _vrDeployer.executeInVR(cmd.getRouterAccessIp(), KeyStoreUtils.KS_IMPORT_SCRIPT, args, Duration.standardMinutes(15));
|
||||
return new SetupCertificateAnswer(result.isSuccess());
|
||||
}
|
||||
|
||||
|
||||
@ -481,7 +481,7 @@ pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/environment.properties
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/java.security.ciphers
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/management/commons-logging.properties
|
||||
%attr(0755,root,root) %{_unitdir}/%{name}-management.service
|
||||
%attr(0644,root,root) %{_unitdir}/%{name}-management.service
|
||||
%attr(0755,cloud,cloud) %{_localstatedir}/run/%{name}-management.pid
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-setup-management
|
||||
%attr(0755,root,root) %{_bindir}/%{name}-update-xenserver-licenses
|
||||
|
||||
@ -28,8 +28,8 @@ Environment="NAME=cloudstack-management"
|
||||
EnvironmentFile=/etc/default/cloudstack-management
|
||||
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment JAVA_HOME=$( readlink -f $( which java ) | sed s:bin/.*$:: )"
|
||||
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment JARS=$(ls /usr/share/cloudstack-management/lib/*.jar | tr '\n' ':' | sed s'/.$//')"
|
||||
ExecStart=/usr/bin/jsvc $JAVA_DEBUG -home "${JAVA_HOME}" -user "${CLOUDSTACK_USER}" -cp "${JARS}:${CLASSPATH}" -errfile ${LOGDIR}/${NAME}.err -cwd ${LOGDIR} -pidfile "${CLOUDSTACK_PID}" ${JAVA_OPTS} "${BOOTSTRAP_CLASS}"
|
||||
ExecStop=/usr/bin/jsvc -cp "$JARS:$CLASSPATH" -pidfile "$CLOUDSTACK_PID" -stop "$BOOTSTRAP_CLASS"
|
||||
ExecStart=/usr/bin/jsvc $JAVA_DEBUG -home "${JAVA_HOME}" -user "${CLOUDSTACK_USER}" -cp "${JARS}:${CLASSPATH}" -errfile "${LOGDIR}/${NAME}.err" -cwd "${LOGDIR}" -pidfile "${CLOUDSTACK_PID}" "${JAVA_OPTS}" "${BOOTSTRAP_CLASS}"
|
||||
ExecStop=/usr/bin/jsvc -cp "${JARS}:${CLASSPATH}" -pidfile "${CLOUDSTACK_PID}" -stop "${BOOTSTRAP_CLASS}"
|
||||
SuccessExitStatus=143
|
||||
|
||||
[Install]
|
||||
|
||||
@ -16,15 +16,13 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ApiDiscoveryResponse extends BaseResponse {
|
||||
@ -121,4 +119,8 @@ public class ApiDiscoveryResponse extends BaseResponse {
|
||||
public void addApiResponse(ApiResponseResponse apiResponse) {
|
||||
this.apiResponse.add(apiResponse);
|
||||
}
|
||||
|
||||
public Set<ApiResponseResponse> getApiResponse() {
|
||||
return apiResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,15 +16,13 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ApiResponseResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.NAME)
|
||||
@ -61,4 +59,20 @@ public class ApiResponseResponse extends BaseResponse {
|
||||
}
|
||||
this.apiResponse.add(childApiResponse);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Set<ApiResponseResponse> getApiResponse() {
|
||||
return apiResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,21 +16,13 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.discovery;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ComponentLifecycleBase;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
@ -43,13 +35,18 @@ import org.apache.cloudstack.api.response.ApiDiscoveryResponse;
|
||||
import org.apache.cloudstack.api.response.ApiParameterResponse;
|
||||
import org.apache.cloudstack.api.response.ApiResponseResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.reflections.ReflectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.ReflectUtil;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.component.ComponentLifecycleBase;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import javax.inject.Inject;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements ApiDiscoveryService {
|
||||
@ -100,7 +97,8 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A
|
||||
}
|
||||
ApiDiscoveryResponse response = getCmdRequestMap(cmdClass, apiCmdAnnotation);
|
||||
|
||||
String responseName = apiCmdAnnotation.responseObject().getName();
|
||||
Class<? extends BaseResponse> responseClass = apiCmdAnnotation.responseObject();
|
||||
String responseName = responseClass.getName();
|
||||
if (!responseName.contains("SuccessResponse")) {
|
||||
if (!responseApiNameListMap.containsKey(responseName)) {
|
||||
responseApiNameListMap.put(responseName, new ArrayList<String>());
|
||||
@ -109,7 +107,7 @@ public class ApiDiscoveryServiceImpl extends ComponentLifecycleBase implements A
|
||||
}
|
||||
response.setRelated(responseName);
|
||||
|
||||
Field[] responseFields = apiCmdAnnotation.responseObject().getDeclaredFields();
|
||||
Set<Field> responseFields = ReflectionUtils.getAllFields(responseClass);
|
||||
for (Field responseField : responseFields) {
|
||||
ApiResponseResponse responseResponse = getFieldResponseMap(responseField);
|
||||
response.addApiResponse(responseResponse);
|
||||
|
||||
@ -16,34 +16,36 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.discovery;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.command.user.discovery.ListApisCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ListVMsCmd;
|
||||
import org.apache.cloudstack.api.response.ApiDiscoveryResponse;
|
||||
import org.apache.cloudstack.api.response.ApiResponseResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cloudstack.acl.APIChecker;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.command.user.discovery.ListApisCmd;
|
||||
import org.apache.cloudstack.api.response.ApiDiscoveryResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class ApiDiscoveryTest {
|
||||
private static APIChecker s_apiChecker = mock(APIChecker.class);
|
||||
@ -51,14 +53,19 @@ public class ApiDiscoveryTest {
|
||||
private static ApiDiscoveryServiceImpl s_discoveryService = new ApiDiscoveryServiceImpl();
|
||||
|
||||
private static Class<?> testCmdClass = ListApisCmd.class;
|
||||
private static Class<?> listVMsCmdClass = ListVMsCmd.class;
|
||||
private static User testUser;
|
||||
private static String testApiName;
|
||||
private static String listVmsCmdName;
|
||||
private static String testApiDescription;
|
||||
private static String testApiSince;
|
||||
private static boolean testApiAsync;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws ConfigurationException {
|
||||
|
||||
listVmsCmdName = listVMsCmdClass.getAnnotation(APICommand.class).name();
|
||||
|
||||
testApiName = testCmdClass.getAnnotation(APICommand.class).name();
|
||||
testApiDescription = testCmdClass.getAnnotation(APICommand.class).description();
|
||||
testApiSince = testCmdClass.getAnnotation(APICommand.class).since();
|
||||
@ -75,6 +82,7 @@ public class ApiDiscoveryTest {
|
||||
|
||||
Set<Class<?>> cmdClasses = new HashSet<Class<?>>();
|
||||
cmdClasses.add(ListApisCmd.class);
|
||||
cmdClasses.add(ListVMsCmd.class);
|
||||
s_discoveryService.start();
|
||||
s_discoveryService.cacheResponseMap(cmdClasses);
|
||||
}
|
||||
@ -82,6 +90,7 @@ public class ApiDiscoveryTest {
|
||||
@Test
|
||||
public void verifyListSingleApi() throws Exception {
|
||||
ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser, testApiName);
|
||||
assertNotNull("Responses should not be null", responses);
|
||||
if (responses != null) {
|
||||
ApiDiscoveryResponse response = responses.getResponses().get(0);
|
||||
assertTrue("No. of response items should be one", responses.getCount() == 1);
|
||||
@ -95,12 +104,25 @@ public class ApiDiscoveryTest {
|
||||
@Test
|
||||
public void verifyListApis() throws Exception {
|
||||
ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser, null);
|
||||
assertNotNull("Responses should not be null", responses);
|
||||
if (responses != null) {
|
||||
assertTrue("No. of response items > 1", responses.getCount().intValue() == 1);
|
||||
assertTrue("No. of response items > 2", responses.getCount().intValue() == 2);
|
||||
for (ApiDiscoveryResponse response : responses.getResponses()) {
|
||||
assertFalse("API name is empty", response.getName().isEmpty());
|
||||
assertFalse("API description is empty", response.getDescription().isEmpty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyListVirtualMachinesTagsField() throws Exception {
|
||||
ListResponse<ApiDiscoveryResponse> responses = (ListResponse<ApiDiscoveryResponse>)s_discoveryService.listApis(testUser, listVmsCmdName);
|
||||
assertNotNull("Response should not be null", responses);
|
||||
if (responses != null) {
|
||||
assertEquals("No. of response items should be one", 1, (int) responses.getCount());
|
||||
ApiDiscoveryResponse response = responses.getResponses().get(0);
|
||||
List<ApiResponseResponse> tagsResponse = response.getApiResponse().stream().filter(resp -> StringUtils.equals(resp.getName(), "tags")).collect(Collectors.toList());
|
||||
assertEquals("Tags field should be present in listVirtualMachines response fields", tagsResponse.size(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user