Skip to content

Commit f3cc57f

Browse files
committed
Merge branch 'master' into ui-vpc-redesign
2 parents f52a833 + 3d16e82 commit f3cc57f

44 files changed

Lines changed: 1234 additions & 1203 deletions

File tree

Some content is hidden

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

api/src/com/cloud/event/EventTypes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public class EventTypes {
103103
public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN";
104104
public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE";
105105
public static final String EVENT_PORTABLE_IP_ASSIGN = "PORTABLE.IPASSIGN";
106-
public static final String EVENT_PORTABLE_IP_RELEASE = "PORTABLEIPRELEASE";
106+
public static final String EVENT_PORTABLE_IP_RELEASE = "PORTABLE.IPRELEASE";
107107
public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
108108
public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
109109
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";

api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ public long getEntityOwnerId() {
191191

192192
@Override
193193
public String getEventType() {
194-
return EventTypes.EVENT_NET_IP_ASSIGN;
194+
if (isPortable()) {
195+
return EventTypes.EVENT_PORTABLE_IP_ASSIGN;
196+
} else {
197+
return EventTypes.EVENT_NET_IP_ASSIGN;
198+
}
195199
}
196200

197201
@Override

api/src/org/apache/cloudstack/api/command/user/address/DisassociateIPAddrCmd.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void execute() throws InsufficientAddressCapacityException{
7878
if (!isPortable(id)) {
7979
result = _networkService.releaseIpAddress(getIpAddressId());
8080
} else {
81-
result = _networkService.releaseIpAddress(getIpAddressId());
81+
result = _networkService.releasePortableIpAddress(getIpAddressId());
8282
}
8383
if (result) {
8484
SuccessResponse response = new SuccessResponse(getCommandName());
@@ -90,7 +90,11 @@ public void execute() throws InsufficientAddressCapacityException{
9090

9191
@Override
9292
public String getEventType() {
93-
return EventTypes.EVENT_NET_IP_RELEASE;
93+
if (!isPortable(id)) {
94+
return EventTypes.EVENT_NET_IP_RELEASE;
95+
} else {
96+
return EventTypes.EVENT_PORTABLE_IP_RELEASE;
97+
}
9498
}
9599

96100
@Override

api/src/org/apache/cloudstack/api/command/user/loadbalancer/ListLoadBalancerRulesCmd.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.cloudstack.api.response.IPAddressResponse;
2828
import org.apache.cloudstack.api.response.ListResponse;
2929
import org.apache.cloudstack.api.response.LoadBalancerResponse;
30+
import org.apache.cloudstack.api.response.NetworkResponse;
3031
import org.apache.cloudstack.api.response.UserVmResponse;
3132
import org.apache.cloudstack.api.response.ZoneResponse;
3233
import org.apache.log4j.Logger;
@@ -62,6 +63,10 @@ public class ListLoadBalancerRulesCmd extends BaseListTaggedResourcesCmd {
6263
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class,
6364
description = "the availability zone ID")
6465
private Long zoneId;
66+
67+
@Parameter(name = ApiConstants.NETWORK_ID, type = CommandType.UUID, entityType = NetworkResponse.class,
68+
description = "list by network id the rule belongs to")
69+
private Long networkId;
6570

6671
// ///////////////////////////////////////////////////
6772
// ///////////////// Accessors ///////////////////////
@@ -86,6 +91,10 @@ public Long getVirtualMachineId() {
8691
public Long getZoneId() {
8792
return zoneId;
8893
}
94+
95+
public Long getNetworkId() {
96+
return networkId;
97+
}
8998

9099
// ///////////////////////////////////////////////////
91100
// ///////////// API Implementation///////////////////

api/src/org/apache/cloudstack/api/command/user/vm/RestoreVMCmd.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import com.cloud.user.UserContext;
3636
import com.cloud.uservm.UserVm;
3737

38-
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template or new template", responseObject=UserVmResponse.class, since="3.0.0")
38+
@APICommand(name = "restoreVirtualMachine", description="Restore a VM to original template/ISO or new template/ISO", responseObject=UserVmResponse.class, since="3.0.0")
3939
public class RestoreVMCmd extends BaseAsyncCmd {
4040
public static final Logger s_logger = Logger.getLogger(RestoreVMCmd.class);
4141
private static final String s_name = "restorevmresponse";
@@ -44,9 +44,10 @@ public class RestoreVMCmd extends BaseAsyncCmd {
4444
required=true, description="Virtual Machine ID")
4545
private Long vmId;
4646

47-
@Parameter(name=ApiConstants.TEMPLATE_ID, type=CommandType.UUID, entityType = TemplateResponse.class, description="an optional template Id to restore vm from the new template")
47+
@Parameter(name=ApiConstants.TEMPLATE_ID, type=CommandType.UUID, entityType = TemplateResponse.class, description="an optional template Id to restore vm from the new template. This can be an ISO id in case of restore vm deployed using ISO")
4848
private Long templateId;
4949

50+
5051
@Override
5152
public String getEventType() {
5253
return EventTypes.EVENT_VM_RESTORE;

api/src/org/apache/cloudstack/api/response/LoadBalancerResponse.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ public class LoadBalancerResponse extends BaseResponse implements ControlledEnti
5757
@SerializedName(ApiConstants.ALGORITHM)
5858
@Param(description = "the load balancer algorithm (source, roundrobin, leastconn)")
5959
private String algorithm;
60+
61+
@SerializedName(ApiConstants.NETWORK_ID)
62+
@Param(description = "the id of the guest network the lb rule belongs to")
63+
private String networkId;
6064

6165
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")
6266
private String cidrList;
63-
67+
6468
@SerializedName(ApiConstants.ACCOUNT)
6569
@Param(description = "the account of the load balancer rule")
6670
private String accountName;
@@ -89,6 +93,7 @@ public class LoadBalancerResponse extends BaseResponse implements ControlledEnti
8993

9094
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with load balancer", responseObject = ResourceTagResponse.class)
9195
private List<ResourceTagResponse> tags;
96+
9297

9398
public void setId(String id) {
9499
this.id = id;
@@ -160,5 +165,9 @@ public void setProjectName(String projectName) {
160165
public void setTags(List<ResourceTagResponse> tags) {
161166
this.tags = tags;
162167
}
168+
169+
public void setNetworkId(String networkId) {
170+
this.networkId = networkId;
171+
}
163172

164173
}

engine/schema/src/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,10 @@ protected void upgrade(String dbVersion, String currentVersion) {
261261
}
262262

263263
txn.commit();
264-
} finally {
264+
} catch (CloudRuntimeException e){
265+
s_logger.error("Unable to upgrade the database", e);
266+
throw new CloudRuntimeException("Unable to upgrade the database", e);
267+
}finally {
265268
txn.close();
266269
}
267270
}

engine/schema/src/com/cloud/upgrade/dao/Upgrade302to40.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.cloud.upgrade.dao;
1919

2020
import java.io.File;
21+
import java.io.UnsupportedEncodingException;
2122
import java.sql.Connection;
2223
import java.sql.PreparedStatement;
2324
import java.sql.ResultSet;
@@ -72,6 +73,7 @@ public void performDataMigration(Connection conn) {
7273
fixForeignKeys(conn);
7374
setupExternalNetworkDevices(conn);
7475
fixZoneUsingExternalDevices(conn);
76+
encryptConfig(conn);
7577
}
7678

7779
@Override
@@ -1079,4 +1081,43 @@ private void fixZoneUsingExternalDevices(Connection conn) {
10791081
s_logger.info("Successfully upgraded networks using F5 and SRX devices to have a entry in the network_external_lb_device_map and network_external_firewall_device_map");
10801082
}
10811083
}
1084+
1085+
private void encryptConfig(Connection conn){
1086+
//Encrypt config params and change category to Hidden
1087+
s_logger.debug("Encrypting Config values");
1088+
PreparedStatement pstmt = null;
1089+
ResultSet rs = null;
1090+
try {
1091+
pstmt = conn.prepareStatement("select name, value from `cloud`.`configuration` where name in ('router.ram.size', 'secondary.storage.vm', 'security.hash.key') and category <> 'Hidden'");
1092+
rs = pstmt.executeQuery();
1093+
while (rs.next()) {
1094+
String name = rs.getString(1);
1095+
String value = rs.getString(2);
1096+
if (value == null) {
1097+
continue;
1098+
}
1099+
String encryptedValue = DBEncryptionUtil.encrypt(value);
1100+
pstmt = conn.prepareStatement("update `cloud`.`configuration` set value=?, category = 'Hidden' where name=?");
1101+
pstmt.setBytes(1, encryptedValue.getBytes("UTF-8"));
1102+
pstmt.setString(2, name);
1103+
pstmt.executeUpdate();
1104+
}
1105+
} catch (SQLException e) {
1106+
throw new CloudRuntimeException("Unable encrypt configuration values ", e);
1107+
} catch (UnsupportedEncodingException e) {
1108+
throw new CloudRuntimeException("Unable encrypt configuration values ", e);
1109+
} finally {
1110+
try {
1111+
if (rs != null) {
1112+
rs.close();
1113+
}
1114+
1115+
if (pstmt != null) {
1116+
pstmt.close();
1117+
}
1118+
} catch (SQLException e) {
1119+
}
1120+
}
1121+
s_logger.debug("Done encrypting Config values");
1122+
}
10821123
}

engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void performDataMigration(Connection conn) {
7676
addHostDetailsIndex(conn);
7777
updateNetworksForPrivateGateways(conn);
7878
removeFirewallServiceFromSharedNetworkOfferingWithSGService(conn);
79+
fix22xKVMSnapshots(conn);
7980
}
8081

8182
private void updateSystemVmTemplates(Connection conn) {
@@ -759,7 +760,7 @@ private void removeFirewallServiceFromSharedNetworkOfferingWithSGService(Connect
759760
while (rs.next()) {
760761
long id = rs.getLong(1);
761762
// remove Firewall service for SG shared network offering
762-
pstmt = conn.prepareStatement("DELETE `cloud`.`ntwk_offering_service_map` where network_offering_id=? and service='Firewall'");
763+
pstmt = conn.prepareStatement("DELETE from `cloud`.`ntwk_offering_service_map` where network_offering_id=? and service='Firewall'");
763764
pstmt.setLong(1, id);
764765
pstmt.executeUpdate();
765766
}
@@ -779,4 +780,43 @@ private void removeFirewallServiceFromSharedNetworkOfferingWithSGService(Connect
779780
}
780781
}
781782

783+
private void fix22xKVMSnapshots(Connection conn) {
784+
PreparedStatement pstmt = null;
785+
ResultSet rs = null;
786+
s_logger.debug("Updating KVM snapshots");
787+
try {
788+
pstmt = conn.prepareStatement("select id, backup_snap_id from `cloud`.`snapshots` where hypervisor_type='KVM' and removed is null and backup_snap_id is not null");
789+
rs = pstmt.executeQuery();
790+
while (rs.next()) {
791+
long id = rs.getLong(1);
792+
String backUpPath = rs.getString(2);
793+
// Update Backup Path. Remove anything before /snapshots/
794+
// e.g 22x Path /mnt/0f14da63-7033-3ca5-bdbe-fa62f4e2f38a/snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
795+
// Above path should change to /snapshots/1/2/6/i-2-6-VM_ROOT-6_20121219072022
796+
int index = backUpPath.indexOf("snapshots"+File.separator);
797+
if (index > 1){
798+
String correctedPath = File.separator + backUpPath.substring(index);
799+
s_logger.debug("Updating Snapshot with id: "+id+" original backup path: "+backUpPath+ " updated backup path: "+correctedPath);
800+
pstmt = conn.prepareStatement("UPDATE `cloud`.`snapshots` set backup_snap_id=? where id = ?");
801+
pstmt.setString(1, correctedPath);
802+
pstmt.setLong(2, id);
803+
pstmt.executeUpdate();
804+
}
805+
}
806+
s_logger.debug("Done updating KVM snapshots");
807+
} catch (SQLException e) {
808+
throw new CloudRuntimeException("Unable to update backup id for KVM snapshots", e);
809+
} finally {
810+
try {
811+
if (rs != null) {
812+
rs.close();
813+
}
814+
815+
if (pstmt != null) {
816+
pstmt.close();
817+
}
818+
} catch (SQLException e) {
819+
}
820+
}
821+
}
782822
}

engine/storage/src/org/apache/cloudstack/storage/allocator/AbstractStoragePoolAllocator.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,6 @@ protected boolean filter(ExcludeList avoid, StoragePool pool, DiskProfile dskCh,
167167
return false;
168168
}
169169

170-
DiskOfferingVO diskOffering = _diskOfferingDao.findById(dskCh.getDiskOfferingId());
171-
if (diskOffering.getSystemUse() && pool.getPoolType() == StoragePoolType.RBD) {
172-
s_logger.debug("Skipping RBD pool " + pool.getName() + " as a suitable pool. RBD is not supported for System VM's");
173-
return false;
174-
}
175-
176170

177171
Long clusterId = pool.getClusterId();
178172
ClusterVO cluster = _clusterDao.findById(clusterId);

0 commit comments

Comments
 (0)