Skip to content

Commit 95a37e6

Browse files
authored
Merge branch 'apache:main' into main
2 parents 3ebf863 + f75a194 commit 95a37e6

File tree

18 files changed

+229
-62
lines changed

18 files changed

+229
-62
lines changed

agent/src/main/java/com/cloud/agent/resource/consoleproxy/ConsoleProxyResource.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,8 @@ protected void runInContext() {
397397
}
398398

399399
public String authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket,
400-
Boolean isReauthentication, String sessionToken) {
401-
402-
ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken);
400+
Boolean isReauthentication, String sessionToken, String clientAddress) {
401+
ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken, clientAddress);
403402
cmd.setReauthenticating(isReauthentication);
404403

405404
ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();

api/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public interface ConsoleAccessManager extends Manager, Configurable {
4444

4545
void removeSessions(String[] sessionUuids);
4646

47-
void acquireSession(String sessionUuid);
47+
void acquireSession(String sessionUuid, String clientAddress);
4848

4949
String genAccessTicket(String host, String port, String sid, String tag, String sessionUuid);
5050
String genAccessTicket(String host, String port, String sid, String tag, Date normalizedHashTime, String sessionUuid);

core/src/main/java/com/cloud/agent/api/ConsoleAccessAuthenticationCommand.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ConsoleAccessAuthenticationCommand extends AgentControlCommand {
2727
private String _sid;
2828
private String _ticket;
2929
private String sessionUuid;
30+
private String clientAddress;
3031

3132
private boolean _isReauthenticating;
3233

@@ -35,13 +36,14 @@ public ConsoleAccessAuthenticationCommand() {
3536
}
3637

3738
public ConsoleAccessAuthenticationCommand(String host, String port, String vmId, String sid, String ticket,
38-
String sessiontkn) {
39+
String sessiontkn, String clientAddress) {
3940
_host = host;
4041
_port = port;
4142
_vmId = vmId;
4243
_sid = sid;
4344
_ticket = ticket;
4445
sessionUuid = sessiontkn;
46+
this.clientAddress = clientAddress;
4547
}
4648

4749
public String getHost() {
@@ -79,4 +81,12 @@ public String getSessionUuid() {
7981
public void setSessionUuid(String sessionUuid) {
8082
this.sessionUuid = sessionUuid;
8183
}
84+
85+
public String getClientAddress() {
86+
return clientAddress;
87+
}
88+
89+
public void setClientAddress(String clientAddress) {
90+
this.clientAddress = clientAddress;
91+
}
8292
}

engine/schema/src/main/java/com/cloud/storage/VolumeVO.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,34 @@ public class VolumeVO implements Volume {
4848
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
4949
@GeneratedValue(strategy = GenerationType.TABLE)
5050
@Column(name = "id")
51-
long id;
51+
private long id;
5252

5353
@Column(name = "last_id")
5454
private long lastId;
5555

5656
@Column(name = "name")
57-
String name;
57+
private String name;
5858

5959
@Column(name = "pool_id")
60-
Long poolId;
60+
private Long poolId;
6161

6262
@Column(name = "last_pool_id")
63-
Long lastPoolId;
63+
private Long lastPoolId;
6464

6565
@Column(name = "account_id")
66-
long accountId;
66+
private long accountId;
6767

6868
@Column(name = "domain_id")
69-
long domainId;
69+
private long domainId;
7070

7171
@Column(name = "instance_id")
72-
Long instanceId = null;
72+
private Long instanceId = null;
7373

7474
@Column(name = "device_id")
75-
Long deviceId = null;
75+
private Long deviceId = null;
7676

7777
@Column(name = "size")
78-
Long size;
78+
private Long size;
7979

8080
@Column(name = "min_iops")
8181
private Long minIops;
@@ -84,50 +84,50 @@ public class VolumeVO implements Volume {
8484
private Long maxIops;
8585

8686
@Column(name = "folder")
87-
String folder;
87+
private String folder;
8888

8989
@Column(name = "path")
90-
String path;
90+
private String path;
9191

9292
@Column(name = "pod_id")
93-
Long podId;
93+
private Long podId;
9494

9595
@Column(name = "created")
96-
Date created;
96+
private Date created;
9797

9898
@Column(name = "attached")
9999
@Temporal(value = TemporalType.TIMESTAMP)
100-
Date attached;
100+
private Date attached;
101101

102102
@Column(name = "data_center_id")
103-
long dataCenterId;
103+
private long dataCenterId;
104104

105105
@Column(name = "host_ip")
106-
String hostip;
106+
private String hostIp;
107107

108108
@Column(name = "disk_offering_id")
109-
long diskOfferingId;
109+
private long diskOfferingId;
110110

111111
@Column(name = "template_id")
112-
Long templateId;
112+
private Long templateId;
113113

114114
@Column(name = "first_snapshot_backup_uuid")
115-
String firstSnapshotBackupUuid;
115+
private String firstSnapshotBackupUuid;
116116

117117
@Column(name = "volume_type")
118118
@Enumerated(EnumType.STRING)
119-
Type volumeType = Volume.Type.UNKNOWN;
119+
private Type volumeType = Volume.Type.UNKNOWN;
120120

121121
@Column(name = "pool_type")
122122
@Convert(converter = StoragePoolTypeConverter.class)
123-
StoragePoolType poolType;
123+
private StoragePoolType poolType;
124124

125125
@Column(name = GenericDao.REMOVED_COLUMN)
126-
Date removed;
126+
private Date removed;
127127

128128
@Column(name = "updated")
129129
@Temporal(value = TemporalType.TIMESTAMP)
130-
Date updated;
130+
private Date updated;
131131

132132
@Column(name = "update_count", updatable = true, nullable = false)
133133
protected long updatedCount; // This field should be updated everytime the
@@ -136,17 +136,17 @@ public class VolumeVO implements Volume {
136136
// dao code.
137137

138138
@Column(name = "recreatable")
139-
boolean recreatable;
139+
private boolean recreatable;
140140

141141
@Column(name = "state")
142142
@Enumerated(value = EnumType.STRING)
143143
private State state;
144144

145145
@Column(name = "chain_info", length = 65535)
146-
String chainInfo;
146+
private String chainInfo;
147147

148148
@Column(name = "uuid")
149-
String uuid;
149+
private String uuid;
150150

151151
@Column(name = "format")
152152
private Storage.ImageFormat format;
@@ -171,7 +171,7 @@ public class VolumeVO implements Volume {
171171

172172
@Transient
173173
// @Column(name="reservation")
174-
String reservationId;
174+
private String reservationId;
175175

176176
@Column(name = "hv_ss_reserve")
177177
private Integer hypervisorSnapshotReserve;
@@ -431,11 +431,11 @@ public void setPath(String path) {
431431
}
432432

433433
public String getHostIp() {
434-
return hostip;
434+
return hostIp;
435435
}
436436

437437
public void setHostIp(String hostip) {
438-
this.hostip = hostip;
438+
this.hostIp = hostip;
439439
}
440440

441441
public void setPodId(Long podId) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
import com.cloud.upgrade.dao.Upgrade41900to41910;
9090
import com.cloud.upgrade.dao.Upgrade41910to42000;
9191
import com.cloud.upgrade.dao.Upgrade42000to42010;
92+
import com.cloud.upgrade.dao.Upgrade42010to42100;
9293
import com.cloud.upgrade.dao.Upgrade420to421;
9394
import com.cloud.upgrade.dao.Upgrade421to430;
9495
import com.cloud.upgrade.dao.Upgrade430to440;
@@ -232,6 +233,7 @@ public DatabaseUpgradeChecker() {
232233
.next("4.19.0.0", new Upgrade41900to41910())
233234
.next("4.19.1.0", new Upgrade41910to42000())
234235
.next("4.20.0.0", new Upgrade42000to42010())
236+
.next("4.20.1.0", new Upgrade42010to42100())
235237
.build();
236238
}
237239

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.upgrade.dao;
18+
19+
import com.cloud.upgrade.SystemVmTemplateRegistration;
20+
import com.cloud.utils.exception.CloudRuntimeException;
21+
22+
import java.io.InputStream;
23+
import java.sql.Connection;
24+
25+
public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
26+
private SystemVmTemplateRegistration systemVmTemplateRegistration;
27+
28+
@Override
29+
public String[] getUpgradableVersionRange() {
30+
return new String[] {"4.20.1.0", "4.21.0.0"};
31+
}
32+
33+
@Override
34+
public String getUpgradedVersion() {
35+
return "4.21.0.0";
36+
}
37+
38+
@Override
39+
public boolean supportsRollingUpgrade() {
40+
return false;
41+
}
42+
43+
@Override
44+
public InputStream[] getPrepareScripts() {
45+
final String scriptFile = "META-INF/db/schema-42010to42100.sql";
46+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
47+
if (script == null) {
48+
throw new CloudRuntimeException("Unable to find " + scriptFile);
49+
}
50+
51+
return new InputStream[] {script};
52+
}
53+
54+
@Override
55+
public void performDataMigration(Connection conn) {
56+
}
57+
58+
@Override
59+
public InputStream[] getCleanupScripts() {
60+
final String scriptFile = "META-INF/db/schema-42010to42100-cleanup.sql";
61+
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
62+
if (script == null) {
63+
throw new CloudRuntimeException("Unable to find " + scriptFile);
64+
}
65+
66+
return new InputStream[] {script};
67+
}
68+
69+
private void initSystemVmTemplateRegistration() {
70+
systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
71+
}
72+
73+
@Override
74+
public void updateSystemVmTemplates(Connection conn) {
75+
logger.debug("Updating System Vm template IDs");
76+
initSystemVmTemplateRegistration();
77+
try {
78+
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
79+
} catch (Exception e) {
80+
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
81+
}
82+
}
83+
}

engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public class ConsoleSessionVO {
6464
@Column(name = "removed")
6565
private Date removed;
6666

67+
@Column(name = "console_endpoint_creator_address")
68+
private String consoleEndpointCreatorAddress;
69+
70+
@Column(name = "client_address")
71+
private String clientAddress;
72+
6773
public long getId() {
6874
return id;
6975
}
@@ -135,4 +141,20 @@ public Date getAcquired() {
135141
public void setAcquired(Date acquired) {
136142
this.acquired = acquired;
137143
}
144+
145+
public String getConsoleEndpointCreatorAddress() {
146+
return consoleEndpointCreatorAddress;
147+
}
148+
149+
public void setConsoleEndpointCreatorAddress(String consoleEndpointCreatorAddress) {
150+
this.consoleEndpointCreatorAddress = consoleEndpointCreatorAddress;
151+
}
152+
153+
public String getClientAddress() {
154+
return clientAddress;
155+
}
156+
157+
public void setClientAddress(String clientAddress) {
158+
this.clientAddress = clientAddress;
159+
}
138160
}

engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public interface ConsoleSessionDao extends GenericDao<ConsoleSessionVO, Long> {
3333

3434
int expungeSessionsOlderThanDate(Date date);
3535

36-
void acquireSession(String sessionUuid);
36+
void acquireSession(String sessionUuid, String clientAddress);
3737

3838
int expungeByVmList(List<Long> vmIds, Long batchSize);
3939
}

engine/schema/src/main/java/com/cloud/vm/dao/ConsoleSessionDaoImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ public int expungeSessionsOlderThanDate(Date date) {
6262
}
6363

6464
@Override
65-
public void acquireSession(String sessionUuid) {
65+
public void acquireSession(String sessionUuid, String clientAddress) {
6666
ConsoleSessionVO consoleSessionVO = findByUuid(sessionUuid);
6767
consoleSessionVO.setAcquired(new Date());
68+
consoleSessionVO.setClientAddress(clientAddress);
6869
update(consoleSessionVO.getId(), consoleSessionVO);
6970
}
7071

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Licensed to the Apache Software Foundation (ASF) under one
2+
-- or more contributor license agreements. See the NOTICE file
3+
-- distributed with this work for additional information
4+
-- regarding copyright ownership. The ASF licenses this file
5+
-- to you under the Apache License, Version 2.0 (the
6+
-- "License"); you may not use this file except in compliance
7+
-- with the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing,
12+
-- software distributed under the License is distributed on an
13+
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
-- KIND, either express or implied. See the License for the
15+
-- specific language governing permissions and limitations
16+
-- under the License.
17+
18+
--;
19+
-- Schema upgrade cleanup from 4.20.1.0 to 4.21.0.0
20+
--;

0 commit comments

Comments
 (0)