Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@ public enum ApiCommandJobType {
DedicatedGuestVlanRange,
GuestOs,
GuestOsMapping,
Network
Network,
Management
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.Set;

import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.affinity.AffinityGroup;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
import org.apache.cloudstack.api.ApiConstants.HostDetails;
Expand Down Expand Up @@ -64,6 +65,7 @@
import org.apache.cloudstack.api.response.LBStickinessResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.cloudstack.api.response.ManagementServerResponse;
import org.apache.cloudstack.api.response.NetworkACLItemResponse;
import org.apache.cloudstack.api.response.NetworkACLResponse;
import org.apache.cloudstack.api.response.NetworkOfferingResponse;
Expand Down Expand Up @@ -462,4 +464,6 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine
ListResponse<UpgradeRouterTemplateResponse> createUpgradeRouterTemplateResponse(List<Long> jobIds);

SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolean privatekey);

ManagementServerResponse createManagementResponse(ManagementServerHost mgmt);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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 org.apache.cloudstack.api.command.admin.management;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ManagementServerResponse;
import org.apache.log4j.Logger;

@APICommand(name = ListMgmtsCmd.APINAME, description = "Lists management servers.", responseObject = ManagementServerResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListMgmtsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListMgmtsCmd.class.getName());

public static final String APINAME = "listManagementServers";

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = HostResponse.class, description = "the id of the management server")
private Long id;

@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the management server")
private String hostName;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

public String getHostName() {
return hostName;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getCommandName() {
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
}

@Override
public ApiCommandJobType getInstanceType() {
return ApiCommandJobType.Host;
}

@Override
public void execute() {
ListResponse<ManagementServerResponse> response = _queryService.listManagementServers(this);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 org.apache.cloudstack.api.response;

import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
import org.apache.cloudstack.api.EntityReference;

@EntityReference(value = ManagementServerHost.class)
public class ManagementServerResponse extends BaseResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the ID of the management server")
private String id;

@SerializedName(ApiConstants.NAME)
@Param(description = "the name of the management server")
private String name;

@SerializedName(ApiConstants.STATE)
@Param(description = "the state of the management server")
private ManagementServerHost.State state;

@SerializedName(ApiConstants.VERSION)
@Param(description = "the version of the management server")
private String version;

public void setId(String id) {
this.id = id;
}

public void setName(String name) {
this.name = name;
}

public void setState(ManagementServerHost.State state) {
this.state = state;
}

public void setVersion(String version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.cluster;
package org.apache.cloudstack.management;

public interface ManagementServerHost {
enum State {
Up, Down
}

long getId();

public static enum State {
Up, Starting, Down
};
String getUuid();

long getMsid();

State getState();

String getName();

String getVersion();

String getServiceIP();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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 org.apache.cloudstack.management;

import org.apache.cloudstack.api.InternalIdentity;

import java.util.Date;

public interface ManagementServerHostPeer extends InternalIdentity {

long getOwnerMshost();
long getPeerMshost();
long getPeerRunid();
ManagementServerHost.State getPeerState();
Date getLastUpdateTime();
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.host.ListHostTagsCmd;
import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
import org.apache.cloudstack.api.command.admin.management.ListMgmtsCmd;
import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd;
import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd;
Expand Down Expand Up @@ -58,6 +59,7 @@
import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ManagementServerResponse;
import org.apache.cloudstack.api.response.ProjectAccountResponse;
import org.apache.cloudstack.api.response.ProjectInvitationResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
Expand Down Expand Up @@ -141,4 +143,6 @@ public interface QueryService {
ListResponse<StorageTagResponse> searchForStorageTags(ListStorageTagsCmd cmd);

ListResponse<HostTagResponse> searchForHostTags(ListHostTagsCmd cmd);

ListResponse<ManagementServerResponse> listManagementServers(ListMgmtsCmd cmd);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ClusterServicePdu;
import com.cloud.cluster.ClusteredAgentRebalanceService;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.cluster.agentlb.AgentLoadBalancerPlanner;
import com.cloud.cluster.agentlb.HostTransferMapVO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import com.cloud.cluster.ClusterManager;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;

public class ClusteredVirtualMachineManagerImpl extends VirtualMachineManagerImpl implements ClusterManagerListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@

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

import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.log4j.Logger;

public class Upgrade41120to41200 implements DbUpgrade {

final static Logger LOG = Logger.getLogger(Upgrade41120to41200.class);

@Override
public String[] getUpgradableVersionRange() {
return new String[] {"4.11.2.0", "4.12.0.0"};
Expand Down Expand Up @@ -52,7 +57,15 @@ public InputStream[] getPrepareScripts() {

@Override
public void performDataMigration(Connection conn) {
updateManagementServerHostUuid(conn);
}

private void updateManagementServerHostUuid(Connection conn) {
try (final PreparedStatement updateStatement = conn.prepareStatement("UPDATE cloud.mshost SET uuid=UUID()")) {
updateStatement.executeUpdate();
} catch (SQLException e) {
LOG.error("Failed to add an UUID to each management server.", e);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, crea
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(), 'KVM', 'default', 'Windows Server 2019', 276, now(), 0);

-- changed fingerprint type to TEXT, it avoids db exception when creating the certificate issue #3123
ALTER TABLE `cloud`.`sslcerts` MODIFY `fingerprint` TEXT;
ALTER TABLE `cloud`.`sslcerts` MODIFY `fingerprint` TEXT;

-- PR#2578 New column for listManagementServers API call
ALTER TABLE `mshost` ADD COLUMN `uuid` varchar(40) AFTER `name`;
3 changes: 1 addition & 2 deletions framework/cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-api</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.
package com.cloud.cluster;

import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.framework.config.ConfigKey;

import com.cloud.utils.component.Manager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -39,6 +40,7 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.framework.config.ConfigDepot;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.Configurable;
Expand Down Expand Up @@ -951,20 +953,21 @@ public ManagementServerHostVO doInTransaction(final TransactionStatus status) {
mshost = new ManagementServerHostVO();
mshost.setMsid(_msId);
mshost.setRunid(_runId);
mshost.setName(NetUtils.getHostName());
mshost.setName(NetUtils.getCanonicalHostName());
mshost.setVersion(version);
mshost.setServiceIP(_clusterNodeIP);
mshost.setServicePort(_currentServiceAdapter.getServicePort());
mshost.setLastUpdateTime(DateUtil.currentGMTTime());
mshost.setRemoved(null);
mshost.setAlertCount(0);
mshost.setState(ManagementServerHost.State.Up);
mshost.setUuid(UUID.randomUUID().toString());
_mshostDao.persist(mshost);
if (s_logger.isInfoEnabled()) {
s_logger.info("New instance of management server msid " + _msId + ", runId " + _runId + " is being started");
}
} else {
_mshostDao.update(mshost.getId(), _runId, NetUtils.getHostName(), version, _clusterNodeIP, _currentServiceAdapter.getServicePort(),
_mshostDao.update(mshost.getId(), _runId, NetUtils.getCanonicalHostName(), version, _clusterNodeIP, _currentServiceAdapter.getServicePort(),
DateUtil.currentGMTTime());
if (s_logger.isInfoEnabled()) {
s_logger.info("Management server " + _msId + ", runId " + _runId + " is being started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// under the License.
package com.cloud.cluster;

import org.apache.cloudstack.management.ManagementServerHost;

import java.util.List;

public interface ClusterManagerListener {
Expand Down
Loading