Skip to content

Commit 3c9bc07

Browse files
committed
Merge remote-tracking branch 'apache/4.19'
2 parents a35d79a + d99cf93 commit 3c9bc07

File tree

42 files changed

+1451
-336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1451
-336
lines changed

api/src/main/java/org/apache/cloudstack/ca/CAManager.java

+8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ public interface CAManager extends CAService, Configurable, PluggableService {
7777
"15",
7878
"The number of days before expiry of a client certificate, the validations are checked. Admins are alerted when auto-renewal is not allowed, otherwise auto-renewal is attempted.", true, ConfigKey.Scope.Cluster);
7979

80+
81+
ConfigKey<String> CertManagementCustomSubjectAlternativeName = new ConfigKey<>("Advanced", String.class,
82+
"ca.framework.cert.management.custom.san",
83+
"cloudstack.internal",
84+
"The custom Subject Alternative Name that will be added to the management server certificate. " +
85+
"The actual implementation will depend on the configured CA provider.",
86+
false);
87+
8088
/**
8189
* Returns a list of available CA provider plugins
8290
* @return returns list of CAProvider

core/src/main/java/com/cloud/resource/CommandWrapper.java

+27-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919

2020
package com.cloud.resource;
2121

22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
24+
2225
import com.cloud.agent.api.Answer;
2326
import com.cloud.agent.api.Command;
24-
import org.apache.logging.log4j.Logger;
25-
import org.apache.logging.log4j.LogManager;
27+
import com.cloud.utils.exception.CloudRuntimeException;
28+
import com.cloud.utils.script.Script;
2629

2730
public abstract class CommandWrapper<T extends Command, A extends Answer, R extends ServerResource> {
2831
protected Logger logger = LogManager.getLogger(getClass());
@@ -33,4 +36,26 @@ public abstract class CommandWrapper<T extends Command, A extends Answer, R exte
3336
* @return A and the Answer from the command.
3437
*/
3538
public abstract A execute(T command, R serverResource);
39+
40+
protected String sanitizeBashCommandArgument(String input) {
41+
StringBuilder sanitized = new StringBuilder();
42+
for (char c : input.toCharArray()) {
43+
if ("\\\"'`$|&;()<>*?![]{}~".indexOf(c) != -1) {
44+
sanitized.append('\\');
45+
}
46+
sanitized.append(c);
47+
}
48+
return sanitized.toString();
49+
}
50+
51+
public void removeDpdkPort(String portToRemove) {
52+
logger.debug("Removing DPDK port: " + portToRemove);
53+
int port;
54+
try {
55+
port = Integer.valueOf(portToRemove);
56+
} catch (NumberFormatException nfe) {
57+
throw new CloudRuntimeException(String.format("Invalid DPDK port specified: '%s'", portToRemove));
58+
}
59+
Script.executeCommand("ovs-vsctl", "del-port", String.valueOf(port));
60+
}
3661
}

framework/ca/src/main/java/org/apache/cloudstack/framework/ca/CAProvider.java

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.security.GeneralSecurityException;
2323
import java.security.KeyStore;
2424
import java.security.KeyStoreException;
25+
import java.security.cert.CertificateParsingException;
2526
import java.security.cert.X509Certificate;
2627
import java.util.List;
2728
import java.util.Map;
@@ -45,6 +46,7 @@ public interface CAProvider {
4546

4647
/**
4748
* Issues certificate with provided options
49+
*
4850
* @param domainNames
4951
* @param ipAddresses
5052
* @param validityDays
@@ -104,4 +106,6 @@ public interface CAProvider {
104106
* @return returns description
105107
*/
106108
String getDescription();
109+
110+
boolean isManagementCertificate(java.security.cert.Certificate certificate) throws CertificateParsingException;
107111
}

framework/ca/src/main/java/org/apache/cloudstack/framework/ca/CAService.java

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.security.GeneralSecurityException;
2222
import java.security.KeyStore;
2323
import java.security.KeyStoreException;
24+
import java.security.cert.CertificateParsingException;
2425

2526
import javax.net.ssl.SSLContext;
2627
import javax.net.ssl.SSLEngine;
@@ -47,4 +48,6 @@ public interface CAService {
4748
* @return returns char[] passphrase
4849
*/
4950
char[] getKeyStorePassphrase();
51+
52+
boolean isManagementCertificate(java.security.cert.Certificate certificate) throws CertificateParsingException;
5053
}

framework/cluster/src/main/java/com/cloud/cluster/ClusterManager.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// under the License.
1717
package com.cloud.cluster;
1818

19-
import org.apache.cloudstack.management.ManagementServerHost;
2019
import org.apache.cloudstack.framework.config.ConfigKey;
20+
import org.apache.cloudstack.management.ManagementServerHost;
2121

2222
import com.cloud.utils.component.Manager;
2323

@@ -77,6 +77,8 @@ public interface ClusterManager extends Manager {
7777
*/
7878
String getSelfPeerName();
7979

80+
String getSelfNodeIP();
81+
8082
long getManagementNodeId();
8183

8284
/**

framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@
4040
import javax.inject.Inject;
4141
import javax.naming.ConfigurationException;
4242

43-
import com.cloud.cluster.dao.ManagementServerStatusDao;
44-
import org.apache.cloudstack.management.ManagementServerHost;
4543
import org.apache.cloudstack.framework.config.ConfigDepot;
4644
import org.apache.cloudstack.framework.config.ConfigKey;
4745
import org.apache.cloudstack.framework.config.Configurable;
4846
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
47+
import org.apache.cloudstack.management.ManagementServerHost;
4948
import org.apache.cloudstack.utils.identity.ManagementServerNode;
5049

5150
import com.cloud.cluster.dao.ManagementServerHostDao;
5251
import com.cloud.cluster.dao.ManagementServerHostPeerDao;
52+
import com.cloud.cluster.dao.ManagementServerStatusDao;
5353
import com.cloud.utils.DateUtil;
5454
import com.cloud.utils.Profiler;
5555
import com.cloud.utils.component.ComponentLifecycle;
@@ -128,7 +128,7 @@ public ClusterManagerImpl() {
128128
// recursive remote calls between nodes
129129
//
130130
_executor = Executors.newCachedThreadPool(new NamedThreadFactory("Cluster-Worker"));
131-
setRunLevel(ComponentLifecycle.RUN_LEVEL_FRAMEWORK);
131+
setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT);
132132
}
133133

134134
private void registerRequestPdu(final ClusterServiceRequestPdu pdu) {
@@ -473,6 +473,7 @@ public String getSelfPeerName() {
473473
return Long.toString(_msId);
474474
}
475475

476+
@Override
476477
public String getSelfNodeIP() {
477478
return _clusterNodeIP;
478479
}

framework/cluster/src/main/java/com/cloud/cluster/ClusterServiceAdapter.java

-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,5 @@ public interface ClusterServiceAdapter extends Adapter {
2828

2929
public ClusterService getPeerService(String strPeer) throws RemoteException;
3030

31-
public String getServiceEndpointName(String strPeer);
32-
3331
public int getServicePort();
3432
}

framework/cluster/src/main/java/com/cloud/cluster/ClusterServiceServletAdapter.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.inject.Inject;
2424
import javax.naming.ConfigurationException;
2525

26+
import org.apache.cloudstack.ca.CAManager;
2627
import org.apache.cloudstack.framework.config.ConfigDepot;
2728

2829
import com.cloud.cluster.dao.ManagementServerHostDao;
@@ -42,14 +43,16 @@ public class ClusterServiceServletAdapter extends AdapterBase implements Cluster
4243
@Inject
4344
private ManagementServerHostDao _mshostDao;
4445
@Inject
46+
private CAManager caService;
47+
@Inject
4548
protected ConfigDepot _configDepot;
4649

4750
private ClusterServiceServletContainer _servletContainer;
4851

4952
private int _clusterServicePort = DEFAULT_SERVICE_PORT;
5053

5154
public ClusterServiceServletAdapter() {
52-
setRunLevel(ComponentLifecycle.RUN_LEVEL_FRAMEWORK);
55+
setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT);
5356
}
5457

5558
@Override
@@ -64,12 +67,10 @@ public ClusterService getPeerService(String strPeer) throws RemoteException {
6467
String serviceUrl = getServiceEndpointName(strPeer);
6568
if (serviceUrl == null)
6669
return null;
67-
68-
return new ClusterServiceServletImpl(serviceUrl);
70+
return new ClusterServiceServletImpl(serviceUrl, caService);
6971
}
7072

71-
@Override
72-
public String getServiceEndpointName(String strPeer) {
73+
protected String getServiceEndpointName(String strPeer) {
7374
try {
7475
init();
7576
} catch (ConfigurationException e) {
@@ -93,7 +94,7 @@ public int getServicePort() {
9394

9495
private String composeEndpointName(String nodeIP, int port) {
9596
StringBuffer sb = new StringBuffer();
96-
sb.append("http://").append(nodeIP).append(":").append(port).append("/clusterservice");
97+
sb.append("https://").append(nodeIP).append(":").append(port).append("/clusterservice");
9798
return sb.toString();
9899
}
99100

@@ -106,7 +107,8 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
106107
@Override
107108
public boolean start() {
108109
_servletContainer = new ClusterServiceServletContainer();
109-
_servletContainer.start(new ClusterServiceServletHttpHandler(_manager), _clusterServicePort);
110+
_servletContainer.start(new ClusterServiceServletHttpHandler(_manager), _manager.getSelfNodeIP(),
111+
_clusterServicePort, caService);
110112
return true;
111113
}
112114

0 commit comments

Comments
 (0)