api: add command to list management servers (#3150)

* api: add command to list management servers

* api: add number of mangement servers in listInfrastructure command

* ui: add block for mangement servers on infra page

* api name resolution method cleanup
This commit is contained in:
dahn 2019-02-01 19:23:39 +01:00 committed by Gabriel Beims Bräscher
parent 00e6d5991d
commit 58466c8954
40 changed files with 366 additions and 27 deletions

View File

@ -52,5 +52,6 @@ public enum ApiCommandJobType {
DedicatedGuestVlanRange,
GuestOs,
GuestOsMapping,
Network
Network,
Management
}

View File

@ -22,6 +22,7 @@ import java.util.List;
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;
@ -64,6 +65,7 @@ import org.apache.cloudstack.api.response.LBHealthCheckResponse;
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;
@ -462,4 +464,6 @@ public interface ResponseGenerator {
ListResponse<UpgradeRouterTemplateResponse> createUpgradeRouterTemplateResponse(List<Long> jobIds);
SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolean privatekey);
ManagementServerResponse createManagementResponse(ManagementServerHost mgmt);
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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();
}

View File

@ -23,6 +23,7 @@ import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
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;
@ -58,6 +59,7 @@ import org.apache.cloudstack.api.response.HostTagResponse;
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;
@ -141,4 +143,6 @@ public interface QueryService {
ListResponse<StorageTagResponse> searchForStorageTags(ListStorageTagsCmd cmd);
ListResponse<HostTagResponse> searchForHostTags(ListHostTagsCmd cmd);
ListResponse<ManagementServerResponse> listManagementServers(ListMgmtsCmd cmd);
}

View File

@ -69,7 +69,7 @@ import com.cloud.cluster.ClusterManager;
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;

View File

@ -24,7 +24,7 @@ import javax.naming.ConfigurationException;
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 {

View File

@ -19,11 +19,16 @@ package com.cloud.upgrade.dao;
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"};
@ -52,7 +57,15 @@ public class Upgrade41120to41200 implements DbUpgrade {
@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

View File

@ -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`;

View File

@ -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>

View File

@ -22,6 +22,7 @@ import java.util.Map;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

View File

@ -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;

View File

@ -31,6 +31,7 @@ import java.util.Iterator;
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;
@ -39,6 +40,7 @@ import java.util.concurrent.TimeUnit;
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;
@ -951,7 +953,7 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
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());
@ -959,12 +961,13 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager, C
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");

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.cluster;
import org.apache.cloudstack.management.ManagementServerHost;
import java.util.List;
public interface ClusterManagerListener {

View File

@ -29,11 +29,13 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHostPeer;
import com.cloud.utils.DateUtil;
@Entity
@Table(name = "mshost_peer")
public class ManagementServerHostPeerVO {
public class ManagementServerHostPeerVO implements ManagementServerHostPeer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ -77,6 +79,7 @@ public class ManagementServerHostPeerVO {
this.id = id;
}
@Override
public long getOwnerMshost() {
return ownerMshost;
}
@ -85,6 +88,7 @@ public class ManagementServerHostPeerVO {
this.ownerMshost = ownerMshost;
}
@Override
public long getPeerMshost() {
return peerMshost;
}
@ -93,6 +97,7 @@ public class ManagementServerHostPeerVO {
this.peerMshost = peerMshost;
}
@Override
public long getPeerRunid() {
return peerRunid;
}
@ -101,6 +106,7 @@ public class ManagementServerHostPeerVO {
this.peerRunid = peerRunid;
}
@Override
public ManagementServerHost.State getPeerState() {
return peerState;
}
@ -109,6 +115,7 @@ public class ManagementServerHostPeerVO {
this.peerState = peerState;
}
@Override
public Date getLastUpdateTime() {
return lastUpdateTime;
}

View File

@ -17,6 +17,7 @@
package com.cloud.cluster;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -29,6 +30,7 @@ import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.utils.db.GenericDao;
@Entity
@ -40,6 +42,9 @@ public class ManagementServerHostVO implements ManagementServerHost {
@Column(name = "id")
private long id;
@Column(name = "uuid")
private String uuid;
@Column(name = "msid", updatable = true, nullable = false)
private long msid;
@ -81,6 +86,7 @@ public class ManagementServerHostVO implements ManagementServerHost {
this.serviceIP = serviceIP;
this.servicePort = servicePort;
lastUpdateTime = updateTime;
this.uuid = UUID.randomUUID().toString();
}
@Override
@ -92,6 +98,15 @@ public class ManagementServerHostVO implements ManagementServerHost {
this.id = id;
}
@Override
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public long getRunid() {
return runid;
}
@ -109,6 +124,7 @@ public class ManagementServerHostVO implements ManagementServerHost {
this.msid = msid;
}
@Override
public String getName() {
return name;
}

View File

@ -19,8 +19,8 @@ package com.cloud.cluster.dao;
import java.util.Date;
import java.util.List;
import com.cloud.cluster.ManagementServerHost;
import com.cloud.cluster.ManagementServerHost.State;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost.State;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDao;

View File

@ -28,8 +28,8 @@ import java.util.TimeZone;
import org.apache.log4j.Logger;
import com.cloud.cluster.ClusterInvalidSessionException;
import com.cloud.cluster.ManagementServerHost;
import com.cloud.cluster.ManagementServerHost.State;
import org.apache.cloudstack.management.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost.State;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.utils.DateUtil;
import com.cloud.utils.db.DB;

View File

@ -16,7 +16,7 @@
// under the License.
package com.cloud.cluster.dao;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.cluster.ManagementServerHostPeerVO;
import com.cloud.utils.db.GenericDao;

View File

@ -21,7 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.cluster.ManagementServerHostPeerVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;

View File

@ -62,7 +62,7 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.slf4j.MDC;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Snapshot;
import com.cloud.storage.dao.SnapshotDao;

View File

@ -62,7 +62,7 @@ import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
import com.cloud.api.query.dao.TemplateJoinDao;
import com.cloud.cluster.ClusterManager;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.cluster.dao.ManagementServerHostPeerDao;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterDetailsDao;

View File

@ -25,6 +25,7 @@ import com.cloud.capacity.Capacity;
import com.cloud.capacity.CapacityManager;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.capacity.dao.CapacityDaoImpl;
import com.cloud.cluster.dao.ManagementServerHostDao;
import com.cloud.dc.DataCenter;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao;
@ -95,6 +96,8 @@ public class MetricsServiceImpl extends ComponentLifecycleBase implements Metric
private DomainRouterDao domainRouterDao;
@Inject
private CapacityDao capacityDao;
@Inject
private ManagementServerHostDao managementServerHostDao;
protected MetricsServiceImpl() {
super();
@ -138,6 +141,7 @@ public class MetricsServiceImpl extends ComponentLifecycleBase implements Metric
}
}
response.setCpuSockets(cpuSockets);
response.setManagementServers(managementServerHostDao.listAll().size());
return response;
}

View File

@ -59,6 +59,10 @@ public class InfrastructureResponse extends BaseResponse {
@Param(description = "Number of cpu sockets")
private Integer cpuSockets;
@SerializedName("managementservers")
@Param(description = "Number of management servers")
private Integer managementServers;
public InfrastructureResponse() {
setObjectName("infrastructure");
}
@ -98,4 +102,8 @@ public class InfrastructureResponse extends BaseResponse {
public void setCpuSockets(final Integer cpuSockets) {
this.cpuSockets = cpuSockets;
}
public void setManagementServers(Integer managementServers) {
this.managementServers = managementServers;
}
}

View File

@ -16,6 +16,7 @@
// under the License.
package com.cloud.api;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.agent.api.VgpuTypesInfo;
@ -235,6 +236,7 @@ import org.apache.cloudstack.api.response.LBStickinessPolicyResponse;
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;
@ -3975,4 +3977,12 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setDomainName(domain.getName());
return response;
}
public ManagementServerResponse createManagementResponse(ManagementServerHost mgmt) {
ManagementServerResponse response = new ManagementServerResponse();
response.setId(mgmt.getUuid());
response.setName(mgmt.getName());
response.setVersion(mgmt.getVersion());
response.setState(mgmt.getState());
return response;
}
}

View File

@ -25,6 +25,8 @@ import java.util.Set;
import javax.inject.Inject;
import com.cloud.cluster.ManagementServerHostVO;
import com.cloud.cluster.dao.ManagementServerHostDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@ -41,6 +43,7 @@ import org.apache.cloudstack.api.command.admin.host.ListHostTagsCmd;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
import org.apache.cloudstack.api.command.admin.iso.ListIsosCmdByAdmin;
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;
@ -80,6 +83,7 @@ import org.apache.cloudstack.api.response.HostTagResponse;
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;
@ -376,6 +380,9 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
@Inject
private EntityManager _entityMgr;
@Inject
ManagementServerHostDao managementServerHostDao;
/*
* (non-Javadoc)
*
@ -3683,6 +3690,23 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
return resourceDetailResponse;
}
@Override
public ListResponse<ManagementServerResponse> listManagementServers(ListMgmtsCmd cmd) {
ListResponse<ManagementServerResponse> response = new ListResponse<>();
List<ManagementServerResponse> result = new ArrayList<>();
for (ManagementServerHostVO mgmt : managementServerHostDao.listAll()) {
ManagementServerResponse mgmtResponse = new ManagementServerResponse();
mgmtResponse.setId(mgmt.getUuid());
mgmtResponse.setName(mgmt.getName());
mgmtResponse.setState(mgmt.getState());
mgmtResponse.setVersion(mgmt.getVersion());
mgmtResponse.setObjectName("managementserver");
result.add(mgmtResponse);
}
response.setResponses(result);
return response;
}
@Override
public String getConfigComponentName() {
return QueryService.class.getSimpleName();

View File

@ -38,7 +38,7 @@ import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import com.cloud.agent.AgentManager;
import com.cloud.alert.AlertManager;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.configuration.Config;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.DataCenterVO;

View File

@ -19,7 +19,7 @@ package com.cloud.server;
import java.util.List;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.utils.db.Merovingian2;
/**

View File

@ -105,6 +105,7 @@ import org.apache.cloudstack.api.command.admin.iso.ListIsoPermissionsCmdByAdmin;
import org.apache.cloudstack.api.command.admin.iso.ListIsosCmdByAdmin;
import org.apache.cloudstack.api.command.admin.iso.RegisterIsoCmdByAdmin;
import org.apache.cloudstack.api.command.admin.loadbalancer.ListLoadBalancerRuleInstancesCmdByAdmin;
import org.apache.cloudstack.api.command.admin.management.ListMgmtsCmd;
import org.apache.cloudstack.api.command.admin.network.AddNetworkDeviceCmd;
import org.apache.cloudstack.api.command.admin.network.AddNetworkServiceProviderCmd;
import org.apache.cloudstack.api.command.admin.network.CreateManagementNetworkIpRangeCmd;
@ -3068,6 +3069,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
cmdList.add(CreateManagementNetworkIpRangeCmd.class);
cmdList.add(DeleteManagementNetworkIpRangeCmd.class);
cmdList.add(UploadTemplateDirectDownloadCertificate.class);
cmdList.add(ListMgmtsCmd.class);
// Out-of-band management APIs for admins
cmdList.add(EnableOutOfBandManagementForHostCmd.class);

View File

@ -115,7 +115,7 @@ import com.cloud.capacity.CapacityState;
import com.cloud.capacity.CapacityVO;
import com.cloud.capacity.dao.CapacityDao;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.ConfigurationManagerImpl;

View File

@ -60,7 +60,7 @@ import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.log4j.Logger;
import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHost;
import org.apache.cloudstack.management.ManagementServerHost;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterDetailsVO;
import com.cloud.dc.DataCenter;

View File

@ -190,7 +190,8 @@ known_categories = {
'listElastistorInterface': 'Misc',
'cloudian': 'Cloudian',
'Sioc' : 'Sioc',
'Diagnostics': 'Diagnostics'
'Diagnostics': 'Diagnostics',
'Management': 'Management',
}

View File

@ -9739,7 +9739,8 @@ div#details-tab-aclRules td.cidrlist span {
top: 68px;
}
.system-dashboard.zone .status_box li.system-vms .icon {
.system-dashboard.zone .status_box li.system-vms .icon,
.system-dashboard.zone .status_box li.management-servers .icon {
background-position: -408px -399px;
}

View File

@ -1218,6 +1218,15 @@
view-all-title="label.sockets"
view-all-target="sockets"><translate key="label.view.all"/></span>
</li>
<li class="block management-servers">
<span class="header"><translate key="label.management.servers"/></span>
<span class="icon">&nbsp;</span>
<span class="overview total" data-item="managementServerCount"></span>
<span class="button view-all clusters"
tr="label.management.servers" trf="view-all-title"
view-all-title="label.management.servers"
view-all-target="managementServers"><translate key="label.view.all"/></span>
</li>
</ul>
</div>
</div>

View File

@ -1017,6 +1017,7 @@ var dictionary = {
"label.management.ips":"Management IP Addresses",
"label.management.server":"Management Server",
"label.mac.address": "MAC Address",
"label.management.servers":"Management Servers",
"label.mac.address.changes":"MAC Address Changes",
"label.max.cpus":"Max. CPU cores",
"label.max.guest.limit":"Max guest limit",
@ -1225,6 +1226,7 @@ var dictionary = {
"label.number.of.clusters":"Number of Clusters",
"label.number.of.cpu.sockets":"The Number of CPU Sockets",
"label.number.of.hosts":"Number of Hosts",
"label.number.of.management.servers":"Number of Management Servers",
"label.number.of.pods":"Number of Pods",
"label.number.of.system.vms":"Number of System VMs",
"label.number.of.virtual.routers":"Number of Virtual Routers",

View File

@ -984,6 +984,7 @@ var dictionary = {
"label.management": "Administration",
"label.management.ips": "Adresses IP de gestion",
"label.management.server": "Serveur de gestion",
"label.management.servers": "Serveurs de gestion",
"label.max.cpus": "Nombre coeurs CPU max.",
"label.max.guest.limit": "Nombre maximum d'invités",
"label.max.instances": "Instance Max.",
@ -1184,6 +1185,7 @@ var dictionary = {
"label.number.of.clusters": "Nombre de clusters",
"label.number.of.cpu.sockets": "Le nombre de sockets CPU",
"label.number.of.hosts": "Nombre d'Hôtes",
"label.number.of.management.servers":"Nombre de serveurs de gestion",
"label.number.of.pods": "Nombre de Pods",
"label.number.of.system.vms": "Nombre de VM Système",
"label.number.of.virtual.routers": "Nombre de routeurs virtuels",

View File

@ -279,6 +279,7 @@
data.systemVmCount = response.systemvms;
data.virtualRouterCount = response.routers;
data.socketCount = response.cpusockets;
data.managementServerCount = response.managementservers;
args.response.success({
data: data
});
@ -9956,6 +9957,40 @@
};
return listView;
},
managementServers: function () {
var listView = {
id: 'managementservers',
fields: {
name: {
label: 'label.name'
},
id: {
label: 'label.uuid'
},
state: {
label: 'label.state',
indicator: {
'Up': 'on',
'Down': 'off'
}
},
version: {
label: 'label.version'
}
},
dataProvider: function (args) {
$.ajax({
url: createURL('listManagementServers'),
async: false,
success: function (json) {
args.response.success({ data: json.listmanagementserversresponse.managementserver });
}
});
}
};
return listView;
}
}
}
@ -17854,6 +17889,9 @@
},
cpusockets: {
label: 'label.number.of.cpu.sockets'
},
managementServers: {
label: 'label.number.of.management.servers'
}
}, {

View File

@ -117,6 +117,18 @@ public class NetUtils {
return "localhost";
}
public static String getCanonicalHostName() {
try {
InetAddress localAddr = InetAddress.getLocalHost();
if (localAddr != null) {
return localAddr.getCanonicalHostName();
}
} catch (UnknownHostException e) {
s_logger.warn("UnknownHostException when trying to get canonical host name. ", e);
}
return "localhost";
}
public static InetAddress getLocalInetAddress() {
try {
return InetAddress.getLocalHost();