Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RUN (/usr/bin/mysqld_safe &); \
sleep 3; \
mvn -Pdeveloper -pl developer -Ddeploydb; \
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
pip install tools/marvin/dist/Marvin-4.5.0-SNAPSHOT.tar.gz
pip install tools/marvin/dist/Marvin-4.5.1-SNAPSHOT.tar.gz

EXPOSE 8080

Expand Down
2 changes: 1 addition & 1 deletion agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion awsapi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion build/replace.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ MSMNTDIR=/mnt
COMPONENTS-SPEC=components.xml
AWSAPILOG=awsapi.log
REMOTEHOST=localhost
COMMONLIBDIR=client/target/cloud-client-ui-4.5.0-SNAPSHOT/WEB-INF/lib/
COMMONLIBDIR=client/target/cloud-client-ui-4.5.1-SNAPSHOT/WEB-INF/lib/
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion developer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion engine/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion engine/components-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion engine/network/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion engine/orchestration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<build>
Expand Down
2 changes: 1 addition & 1 deletion engine/schema/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-engine</artifactId>
<version>4.5.0-SNAPSHOT</version>
<version>4.5.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
// under the License.
package com.cloud.network.dao;

import java.util.UUID;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.utils.db.Encrypt;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.cloud.network.RemoteAccessVpn;
import java.util.UUID;

@Entity
@Table(name = ("remote_access_vpn"))
Expand All @@ -48,6 +48,7 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
@Column(name = "ip_range")
private String ipRange;

@Encrypt
@Column(name = "ipsec_psk")
private String ipsecPresharedKey;

Expand Down
81 changes: 42 additions & 39 deletions engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java

Large diffs are not rendered by default.

178 changes: 178 additions & 0 deletions engine/schema/src/com/cloud/upgrade/dao/Upgrade450to451.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// 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 com.cloud.upgrade.dao;

import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.TransactionLegacy;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import org.apache.log4j.Logger;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class Upgrade450to451 implements DbUpgrade {
final static Logger s_logger = Logger.getLogger(Upgrade450to451.class);

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.5.0", "4.5.1"};
}

@Override
public String getUpgradedVersion() {
return "4.5.1";
}

@Override
public boolean supportsRollingUpgrade() {
return false;
}

@Override
public File[] getPrepareScripts() {
String script = Script.findScript("", "db/schema-450to451.sql");
if (script == null) {
throw new CloudRuntimeException("Unable to find db/schema-450to451.sql");
}
return new File[] {new File(script)};
}

@Override
public File[] getCleanupScripts() {
String script = Script.findScript("", "db/schema-450to451-cleanup.sql");
if (script == null) {
throw new CloudRuntimeException("Unable to find db/schema-450to451-cleanup.sql");
}

return new File[] {new File(script)};
}

@Override
public void performDataMigration(Connection conn) {
encryptKeyInKeyStore(conn);
encryptIpSecPresharedKeysOfRemoteAccessVpn(conn);
encryptStoragePoolUserInfo(conn);
}

private void encryptKeyInKeyStore(Connection conn) {
PreparedStatement selectStatement = null;
ResultSet selectResultSet = null;
PreparedStatement updateStatement = null;
try {
selectStatement = conn.prepareStatement("SELECT ks.id, ks.key FROM cloud.keystore ks WHERE ks.key IS NOT null");
selectResultSet = selectStatement.executeQuery();
while (selectResultSet.next()) {
updateStatement = conn.prepareStatement("UPDATE cloud.keystore ks SET ks.key = ? WHERE ks.id = ?");
updateStatement.setString(1, DBEncryptionUtil.encrypt(selectResultSet.getString(2)));
updateStatement.setLong(2, selectResultSet.getLong(1));
updateStatement.executeUpdate();
updateStatement.close();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Exception while encrypting key column in keystore table", e);
} finally {
if (selectResultSet != null)
try {
selectResultSet.close();
} catch (SQLException e) {
}
if (selectStatement != null)
try {
selectStatement.close();
} catch (SQLException e) {
}
if (updateStatement != null)
try {
updateStatement.close();
} catch (SQLException e) {
}
}
s_logger.debug("Done encrypting keystore's key column");
}

private void encryptIpSecPresharedKeysOfRemoteAccessVpn(Connection conn) {
PreparedStatement selectStatement = null;
PreparedStatement updateStatement = null;
ResultSet resultSet = null;
try {
selectStatement = conn.prepareStatement("SELECT id, ipsec_psk FROM `cloud`.`remote_access_vpn`");
resultSet = selectStatement.executeQuery();
while (resultSet.next()) {
String preSharedKey = resultSet.getString(2);
updateStatement = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` SET ipsec_psk=? WHERE id=?");
updateStatement.setString(1, DBEncryptionUtil.encrypt(preSharedKey));
updateStatement.setLong(2, resultSet.getLong(1));
updateStatement.executeUpdate();
updateStatement.close();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to update the remote_access_vpn's preshared key ipsec_psk column", e);
} finally {
try {
if (resultSet != null) {
resultSet.close();
}
if ((selectStatement != null) && (!selectStatement.isClosed())) {
selectStatement.close();
}
if ((updateStatement != null) && (!updateStatement.isClosed()))
updateStatement.close();
} catch (SQLException e) {
}
}
s_logger.debug("Done encrypting remote_access_vpn's ipsec_psk column");
}

private void encryptStoragePoolUserInfo(Connection conn) {
List<PreparedStatement> listOfStatements = new ArrayList<PreparedStatement>();
try {
PreparedStatement preparedStatement = conn.prepareStatement("SELECT id, user_info FROM `cloud`.`storage_pool` WHERE user_info IS NOT NULL");
listOfStatements.add(preparedStatement);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
long id = resultSet.getLong(1);
String userInfo = resultSet.getString(2);
String encryptedUserInfo = DBEncryptionUtil.encrypt(userInfo);
preparedStatement = conn.prepareStatement("UPDATE `cloud`.`storage_pool` SET user_info=? WHERE id=?");
listOfStatements.add(preparedStatement);
if (encryptedUserInfo == null)
preparedStatement.setNull(1, 12);
else {
preparedStatement.setBytes(1, encryptedUserInfo.getBytes("UTF-8"));
}
preparedStatement.setLong(2, id);
preparedStatement.executeUpdate();
preparedStatement.close();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable encrypt storage pool user info ", e);
} catch (UnsupportedEncodingException e) {
throw new CloudRuntimeException("Unable encrypt storage pool user info ", e);
} finally {
TransactionLegacy.closePstmts(listOfStatements);
}
s_logger.debug("Done encrypting storage_pool's user_info column");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
// under the License.
package org.apache.cloudstack.engine.cloud.entity.api.db;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.StateMachine;
import com.cloud.utils.fsm.FiniteStateObject;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
Expand All @@ -36,14 +38,11 @@
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.StateMachine;
import com.cloud.utils.fsm.FiniteStateObject;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
import java.security.SecureRandom;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@Entity
@Table(name = "vm_instance")
Expand Down Expand Up @@ -190,7 +189,7 @@ public VMEntityVO(long id, long serviceOfferingId, String name, String instanceN
this.type = type;
this.guestOSId = guestOSId;
this.haEnabled = haEnabled;
vncPassword = Long.toHexString(new Random().nextLong());
vncPassword = Long.toHexString(new SecureRandom().nextLong());
state = State.Stopped;
this.accountId = accountId;
this.domainId = domainId;
Expand Down
Loading