Skip to content

Commit

Permalink
Merge branch 'apache:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
phsm authored Dec 12, 2024
2 parents 3ebf863 + f75a194 commit 95a37e6
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,8 @@ protected void runInContext() {
}

public String authenticateConsoleAccess(String host, String port, String vmId, String sid, String ticket,
Boolean isReauthentication, String sessionToken) {

ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken);
Boolean isReauthentication, String sessionToken, String clientAddress) {
ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(host, port, vmId, sid, ticket, sessionToken, clientAddress);
cmd.setReauthenticating(isReauthentication);

ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public interface ConsoleAccessManager extends Manager, Configurable {

void removeSessions(String[] sessionUuids);

void acquireSession(String sessionUuid);
void acquireSession(String sessionUuid, String clientAddress);

String genAccessTicket(String host, String port, String sid, String tag, String sessionUuid);
String genAccessTicket(String host, String port, String sid, String tag, Date normalizedHashTime, String sessionUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ConsoleAccessAuthenticationCommand extends AgentControlCommand {
private String _sid;
private String _ticket;
private String sessionUuid;
private String clientAddress;

private boolean _isReauthenticating;

Expand All @@ -35,13 +36,14 @@ public ConsoleAccessAuthenticationCommand() {
}

public ConsoleAccessAuthenticationCommand(String host, String port, String vmId, String sid, String ticket,
String sessiontkn) {
String sessiontkn, String clientAddress) {
_host = host;
_port = port;
_vmId = vmId;
_sid = sid;
_ticket = ticket;
sessionUuid = sessiontkn;
this.clientAddress = clientAddress;
}

public String getHost() {
Expand Down Expand Up @@ -79,4 +81,12 @@ public String getSessionUuid() {
public void setSessionUuid(String sessionUuid) {
this.sessionUuid = sessionUuid;
}

public String getClientAddress() {
return clientAddress;
}

public void setClientAddress(String clientAddress) {
this.clientAddress = clientAddress;
}
}
58 changes: 29 additions & 29 deletions engine/schema/src/main/java/com/cloud/storage/VolumeVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,34 @@ public class VolumeVO implements Volume {
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "id")
long id;
private long id;

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

@Column(name = "name")
String name;
private String name;

@Column(name = "pool_id")
Long poolId;
private Long poolId;

@Column(name = "last_pool_id")
Long lastPoolId;
private Long lastPoolId;

@Column(name = "account_id")
long accountId;
private long accountId;

@Column(name = "domain_id")
long domainId;
private long domainId;

@Column(name = "instance_id")
Long instanceId = null;
private Long instanceId = null;

@Column(name = "device_id")
Long deviceId = null;
private Long deviceId = null;

@Column(name = "size")
Long size;
private Long size;

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

@Column(name = "folder")
String folder;
private String folder;

@Column(name = "path")
String path;
private String path;

@Column(name = "pod_id")
Long podId;
private Long podId;

@Column(name = "created")
Date created;
private Date created;

@Column(name = "attached")
@Temporal(value = TemporalType.TIMESTAMP)
Date attached;
private Date attached;

@Column(name = "data_center_id")
long dataCenterId;
private long dataCenterId;

@Column(name = "host_ip")
String hostip;
private String hostIp;

@Column(name = "disk_offering_id")
long diskOfferingId;
private long diskOfferingId;

@Column(name = "template_id")
Long templateId;
private Long templateId;

@Column(name = "first_snapshot_backup_uuid")
String firstSnapshotBackupUuid;
private String firstSnapshotBackupUuid;

@Column(name = "volume_type")
@Enumerated(EnumType.STRING)
Type volumeType = Volume.Type.UNKNOWN;
private Type volumeType = Volume.Type.UNKNOWN;

@Column(name = "pool_type")
@Convert(converter = StoragePoolTypeConverter.class)
StoragePoolType poolType;
private StoragePoolType poolType;

@Column(name = GenericDao.REMOVED_COLUMN)
Date removed;
private Date removed;

@Column(name = "updated")
@Temporal(value = TemporalType.TIMESTAMP)
Date updated;
private Date updated;

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

@Column(name = "recreatable")
boolean recreatable;
private boolean recreatable;

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

@Column(name = "chain_info", length = 65535)
String chainInfo;
private String chainInfo;

@Column(name = "uuid")
String uuid;
private String uuid;

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

@Transient
// @Column(name="reservation")
String reservationId;
private String reservationId;

@Column(name = "hv_ss_reserve")
private Integer hypervisorSnapshotReserve;
Expand Down Expand Up @@ -431,11 +431,11 @@ public void setPath(String path) {
}

public String getHostIp() {
return hostip;
return hostIp;
}

public void setHostIp(String hostip) {
this.hostip = hostip;
this.hostIp = hostip;
}

public void setPodId(Long podId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import com.cloud.upgrade.dao.Upgrade41900to41910;
import com.cloud.upgrade.dao.Upgrade41910to42000;
import com.cloud.upgrade.dao.Upgrade42000to42010;
import com.cloud.upgrade.dao.Upgrade42010to42100;
import com.cloud.upgrade.dao.Upgrade420to421;
import com.cloud.upgrade.dao.Upgrade421to430;
import com.cloud.upgrade.dao.Upgrade430to440;
Expand Down Expand Up @@ -232,6 +233,7 @@ public DatabaseUpgradeChecker() {
.next("4.19.0.0", new Upgrade41900to41910())
.next("4.19.1.0", new Upgrade41910to42000())
.next("4.20.0.0", new Upgrade42000to42010())
.next("4.20.1.0", new Upgrade42010to42100())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
// 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.upgrade.SystemVmTemplateRegistration;
import com.cloud.utils.exception.CloudRuntimeException;

import java.io.InputStream;
import java.sql.Connection;

public class Upgrade42010to42100 extends DbUpgradeAbstractImpl implements DbUpgrade, DbUpgradeSystemVmTemplate {
private SystemVmTemplateRegistration systemVmTemplateRegistration;

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

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

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

@Override
public InputStream[] getPrepareScripts() {
final String scriptFile = "META-INF/db/schema-42010to42100.sql";
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
if (script == null) {
throw new CloudRuntimeException("Unable to find " + scriptFile);
}

return new InputStream[] {script};
}

@Override
public void performDataMigration(Connection conn) {
}

@Override
public InputStream[] getCleanupScripts() {
final String scriptFile = "META-INF/db/schema-42010to42100-cleanup.sql";
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
if (script == null) {
throw new CloudRuntimeException("Unable to find " + scriptFile);
}

return new InputStream[] {script};
}

private void initSystemVmTemplateRegistration() {
systemVmTemplateRegistration = new SystemVmTemplateRegistration("");
}

@Override
public void updateSystemVmTemplates(Connection conn) {
logger.debug("Updating System Vm template IDs");
initSystemVmTemplateRegistration();
try {
systemVmTemplateRegistration.updateSystemVmTemplates(conn);
} catch (Exception e) {
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
}
}
}
22 changes: 22 additions & 0 deletions engine/schema/src/main/java/com/cloud/vm/ConsoleSessionVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public class ConsoleSessionVO {
@Column(name = "removed")
private Date removed;

@Column(name = "console_endpoint_creator_address")
private String consoleEndpointCreatorAddress;

@Column(name = "client_address")
private String clientAddress;

public long getId() {
return id;
}
Expand Down Expand Up @@ -135,4 +141,20 @@ public Date getAcquired() {
public void setAcquired(Date acquired) {
this.acquired = acquired;
}

public String getConsoleEndpointCreatorAddress() {
return consoleEndpointCreatorAddress;
}

public void setConsoleEndpointCreatorAddress(String consoleEndpointCreatorAddress) {
this.consoleEndpointCreatorAddress = consoleEndpointCreatorAddress;
}

public String getClientAddress() {
return clientAddress;
}

public void setClientAddress(String clientAddress) {
this.clientAddress = clientAddress;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public interface ConsoleSessionDao extends GenericDao<ConsoleSessionVO, Long> {

int expungeSessionsOlderThanDate(Date date);

void acquireSession(String sessionUuid);
void acquireSession(String sessionUuid, String clientAddress);

int expungeByVmList(List<Long> vmIds, Long batchSize);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ public int expungeSessionsOlderThanDate(Date date) {
}

@Override
public void acquireSession(String sessionUuid) {
public void acquireSession(String sessionUuid, String clientAddress) {
ConsoleSessionVO consoleSessionVO = findByUuid(sessionUuid);
consoleSessionVO.setAcquired(new Date());
consoleSessionVO.setClientAddress(clientAddress);
update(consoleSessionVO.getId(), consoleSessionVO);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- 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.

--;
-- Schema upgrade cleanup from 4.20.1.0 to 4.21.0.0
--;
Loading

0 comments on commit 95a37e6

Please sign in to comment.