use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.
the class NetworkServiceImpl method createGuestNetwork.
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_CREATE, eventDescription = "creating network")
public Network createGuestNetwork(final CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
final Long networkOfferingId = cmd.getNetworkOfferingId();
String gateway = cmd.getGateway();
final String startIP = cmd.getStartIp();
String endIP = cmd.getEndIp();
final String netmask = cmd.getNetmask();
final String networkDomain = cmd.getNetworkDomain();
final String vlanId = cmd.getVlan();
final String name = cmd.getNetworkName();
final String displayText = cmd.getDisplayText();
final Account caller = CallContext.current().getCallingAccount();
final Long physicalNetworkId = cmd.getPhysicalNetworkId();
Long zoneId = cmd.getZoneId();
final String aclTypeStr = cmd.getAclType();
final Long domainId = cmd.getDomainId();
boolean isDomainSpecific = false;
final Boolean subdomainAccess = cmd.getSubdomainAccess();
final Long vpcId = cmd.getVpcId();
final String startIPv6 = cmd.getStartIpv6();
String endIPv6 = cmd.getEndIpv6();
String ip6Gateway = cmd.getIp6Gateway();
final String ip6Cidr = cmd.getIp6Cidr();
Boolean displayNetwork = cmd.getDisplayNetwork();
final Long aclId = cmd.getAclId();
final String isolatedPvlan = cmd.getIsolatedPvlan();
final String dns1 = cmd.getDns1();
final String dns2 = cmd.getDns2();
final String ipExclusionList = cmd.getIpExclusionList();
final String getDhcpTftpServer = cmd.getDhcpTftpServer();
final String getDhcpBootfileName = cmd.getDhcpBootfileName();
// Validate network offering
final NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
if (ntwkOff == null || ntwkOff.isSystemOnly()) {
final InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering by specified id");
if (ntwkOff != null) {
ex.addProxyObject(ntwkOff.getUuid(), "networkOfferingId");
}
throw ex;
}
if (!GuestType.Private.equals(ntwkOff.getGuestType()) && vpcId == null) {
throw new InvalidParameterValueException("VPC ID is required");
}
if (GuestType.Private.equals(ntwkOff.getGuestType()) && (startIP != null || endIP != null || vpcId != null || gateway != null || netmask != null)) {
throw new InvalidParameterValueException("StartIp/endIp/vpcId/gateway/netmask can't be specified for guest type " + GuestType.Private);
}
// validate physical network and zone
// Check if physical network exists
PhysicalNetwork pNtwk = null;
if (physicalNetworkId != null) {
pNtwk = _physicalNetworkDao.findById(physicalNetworkId);
if (pNtwk == null) {
throw new InvalidParameterValueException("Unable to find a physical network having the specified physical network id");
}
}
if (zoneId == null) {
zoneId = pNtwk.getDataCenterId();
}
if (displayNetwork == null) {
displayNetwork = true;
}
final Zone zone = zoneRepository.findById(zoneId).orElse(null);
if (zone == null) {
throw new InvalidParameterValueException("Specified zone id was not found");
}
if (AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) {
// See DataCenterVO.java
final PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation since specified Zone is currently disabled");
ex.addProxyObject(zone.getUuid(), "zoneId");
throw ex;
}
// Only domain and account ACL types are supported in Acton.
ACLType aclType = null;
if (aclTypeStr != null) {
if (aclTypeStr.equalsIgnoreCase(ACLType.Account.toString())) {
aclType = ACLType.Account;
} else if (aclTypeStr.equalsIgnoreCase(ACLType.Domain.toString())) {
aclType = ACLType.Domain;
} else {
throw new InvalidParameterValueException("Incorrect aclType specified. Check the API documentation for supported types");
}
// In 3.0 all Shared networks should have aclType == Domain, all Isolated networks aclType==Account
if (ntwkOff.getGuestType() != GuestType.Shared) {
if (aclType != ACLType.Account) {
throw new InvalidParameterValueException("AclType should be " + ACLType.Account + " for network of type " + ntwkOff.getGuestType());
}
} else if (ntwkOff.getGuestType() == GuestType.Shared) {
if (!(aclType == ACLType.Domain || aclType == ACLType.Account)) {
throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " or " + ACLType.Account + " for network of type " + GuestType.Shared);
}
}
} else {
aclType = (ntwkOff.getGuestType() == GuestType.Shared) ? ACLType.Domain : ACLType.Account;
}
// Only Admin can create Shared networks
if (ntwkOff.getGuestType() == GuestType.Shared && !_accountMgr.isAdmin(caller.getId())) {
throw new InvalidParameterValueException("Only Admins can create network with guest type " + GuestType.Shared);
}
// Check if the network is domain specific
if (aclType == ACLType.Domain) {
// only Admin can create domain with aclType=Domain
if (!_accountMgr.isAdmin(caller.getId())) {
throw new PermissionDeniedException("Only admin can create networks with aclType=Domain");
}
// only shared networks can be Domain specific
if (ntwkOff.getGuestType() != GuestType.Shared) {
throw new InvalidParameterValueException("Only " + GuestType.Shared + " networks can have aclType=" + ACLType.Domain);
}
if (domainId != null) {
if (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != GuestType.Shared) {
throw new InvalidParameterValueException("Domain level networks are supported just for traffic type " + TrafficType.Guest + " and guest type " + GuestType.Shared);
}
final DomainVO domain = _domainDao.findById(domainId);
if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain by specified id");
}
_accountMgr.checkAccess(caller, domain);
}
isDomainSpecific = true;
} else if (subdomainAccess != null) {
throw new InvalidParameterValueException("Parameter subDomainAccess can be specified only with aclType=Domain");
}
Account owner = null;
if (cmd.getAccountName() != null && domainId != null || cmd.getProjectId() != null) {
owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), domainId, cmd.getProjectId());
} else {
owner = caller;
}
boolean ipv4 = true, ipv6 = false;
if (startIP != null) {
ipv4 = true;
}
if (startIPv6 != null) {
ipv6 = true;
}
if (gateway != null) {
try {
// getByName on a literal representation will only check validity of the address
// http://docs.oracle.com/javase/6/docs/api/java/net/InetAddress.html#getByName(java.lang.String)
final InetAddress gatewayAddress = InetAddress.getByName(gateway);
if (gatewayAddress instanceof Inet6Address) {
ipv6 = true;
} else {
ipv4 = true;
}
} catch (final UnknownHostException e) {
s_logger.error("Unable to convert gateway IP to a InetAddress", e);
throw new InvalidParameterValueException("Gateway parameter is invalid");
}
}
String cidr = cmd.getCidr();
if (ipv4) {
// validate the CIDR
if (cidr != null && !NetUtils.isValidIp4Cidr(cidr)) {
throw new InvalidParameterValueException("Invalid format for the CIDR parameter");
}
// validate gateway with cidr
if (cidr != null && gateway != null && !NetUtils.isIpWithtInCidrRange(gateway, cidr)) {
throw new InvalidParameterValueException("The gateway ip " + gateway + " should be part of the CIDR of the network " + cidr);
}
// if end ip is not specified, default it to startIp
if (startIP != null) {
if (!NetUtils.isValidIp4(startIP)) {
throw new InvalidParameterValueException("Invalid format for the startIp parameter");
}
if (endIP == null) {
endIP = startIP;
} else if (!NetUtils.isValidIp4(endIP)) {
throw new InvalidParameterValueException("Invalid format for the endIp parameter");
}
}
if (startIP != null && endIP != null) {
if (!(gateway != null && netmask != null)) {
throw new InvalidParameterValueException("gateway and netmask should be defined when startIP/endIP are passed in");
}
}
if (gateway != null && netmask != null) {
if (NetUtils.isNetworkorBroadcastIP(gateway, netmask)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("The gateway IP provided is " + gateway + " and netmask is " + netmask + ". The IP is either broadcast or network IP.");
}
throw new InvalidParameterValueException("Invalid gateway IP provided. Either the IP is broadcast or network IP.");
}
if (!NetUtils.isValidIp4(gateway)) {
throw new InvalidParameterValueException("Invalid gateway");
}
if (!NetUtils.isValidIp4Netmask(netmask)) {
throw new InvalidParameterValueException("Invalid netmask");
}
cidr = NetUtils.ipAndNetMaskToCidr(gateway, netmask);
}
checkIpExclusionList(ipExclusionList, cidr, null);
}
if (ipv6) {
// validate the ipv6 CIDR
if (ip6Cidr != null && !NetUtils.isValidIp4Cidr(ip6Cidr)) {
throw new InvalidParameterValueException("Invalid format for the CIDR parameter");
}
if (endIPv6 == null) {
endIPv6 = startIPv6;
}
_networkModel.checkIp6Parameters(startIPv6, endIPv6, ip6Gateway, ip6Cidr);
if (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != GuestType.Shared) {
throw new InvalidParameterValueException("Can only support create IPv6 network with advance shared network!");
}
}
if (isolatedPvlan != null && (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != GuestType.Shared)) {
throw new InvalidParameterValueException("Can only support create Private VLAN network with advance shared network!");
}
if (isolatedPvlan != null && ipv6) {
throw new InvalidParameterValueException("Can only support create Private VLAN network with IPv4!");
}
// Regular user can create Guest Isolated Source Nat enabled network only
if (_accountMgr.isNormalUser(caller.getId()) && (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != GuestType.Isolated && areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
throw new InvalidParameterValueException("Regular user can create a network only from the network offering having traffic type " + TrafficType.Guest + " and network type " + GuestType.Isolated + " with a service " + Service.SourceNat.getName() + " enabled");
}
// Don't allow to specify vlan if the caller is a normal user
if (_accountMgr.isNormalUser(caller.getId()) && (ntwkOff.getSpecifyVlan() || vlanId != null)) {
throw new InvalidParameterValueException("Only ROOT admin and domain admins are allowed to specify vlanId");
}
if (ipv4) {
// For non-root admins check cidr limit - if it's allowed by global config value
if (!_accountMgr.isRootAdmin(caller.getId()) && cidr != null) {
final String[] cidrPair = cidr.split("\\/");
final int cidrSize = Integer.parseInt(cidrPair[1]);
if (cidrSize < _cidrLimit) {
throw new InvalidParameterValueException("Cidr size can't be less than " + _cidrLimit);
}
}
}
// Vlan is created in 1 cases - works in Advance zone only:
// 1) GuestType is Shared
boolean createVlan = startIP != null && endIP != null && zone.getNetworkType() == NetworkType.Advanced && (ntwkOff.getGuestType() == GuestType.Shared || !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat));
if (!createVlan) {
// Only support advance shared network in IPv6, which means createVlan is a must
if (ipv6) {
createVlan = true;
}
}
// Can add vlan range only to the network which allows it
if (createVlan && !ntwkOff.getSpecifyIpRanges()) {
final InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id doesn't support adding multiple ip ranges");
ex.addProxyObject(ntwkOff.getUuid(), "networkOfferingId");
throw ex;
}
if (ntwkOff.getGuestType() != GuestType.Private && gateway == null && cidr != null) {
gateway = NetUtils.getCidrHostAddress(cidr);
}
if (ntwkOff.getGuestType() != GuestType.Private && ip6Gateway == null && ip6Cidr != null) {
ip6Gateway = NetUtils.getCidrHostAddress6(ip6Cidr);
}
if (ntwkOff.getGuestType() == GuestType.Private && (dns1 != null || dns2 != null)) {
throw new InvalidParameterValueException("Network of type Private does not support setting DNS servers");
}
Network network = commitNetwork(networkOfferingId, gateway, startIP, endIP, netmask, networkDomain, vlanId, name, displayText, caller, physicalNetworkId, zoneId, domainId, isDomainSpecific, subdomainAccess, vpcId, startIPv6, endIPv6, ip6Gateway, ip6Cidr, displayNetwork, aclId, isolatedPvlan, ntwkOff, pNtwk, aclType, owner, cidr, createVlan, dns1, dns2, ipExclusionList, getDhcpTftpServer, getDhcpBootfileName);
// if the network offering has persistent set to true, implement the network
if (ntwkOff.getIsPersistent()) {
try {
if (network.getState() == Network.State.Setup) {
s_logger.debug("Network id=" + network.getId() + " is already provisioned");
return network;
}
final DeployDestination dest = new DeployDestination(zone, null, null, null);
final UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId());
final Journal journal = new Journal.LogJournal("Implementing " + network, s_logger);
final ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, caller);
s_logger.debug("Implementing network " + network + " as a part of network provision for persistent network");
final Pair<? extends NetworkGuru, ? extends Network> implementedNetwork = _networkMgr.implementNetwork(network.getId(), dest, context);
if (implementedNetwork == null || implementedNetwork.first() == null) {
s_logger.warn("Failed to provision the network " + network);
}
network = implementedNetwork.second();
} catch (final ResourceUnavailableException ex) {
s_logger.warn("Failed to implement persistent guest network " + network + "due to: " + ex.getMessage());
final CloudRuntimeException e = new CloudRuntimeException("Failed to implement persistent guest network", ex);
e.addProxyObject(network.getUuid(), "networkId");
throw e;
}
}
return network;
}
use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.
the class AlertManagerImpl method checkForAlerts.
public void checkForAlerts() {
recalculateCapacity();
// abort if we can't possibly send an alert...
if (_emailAlert == null) {
return;
}
// Get all datacenters, pods and clusters in the system.
final List<Zone> zones = zoneRepository.findByRemovedIsNull();
final List<ClusterVO> clusterList = _clusterDao.listAll();
final List<HostPodVO> podList = _podDao.listAll();
// Get capacity types at different levels
final List<Short> dataCenterCapacityTypes = getCapacityTypesAtZoneLevel();
final List<Short> podCapacityTypes = getCapacityTypesAtPodLevel();
final List<Short> clusterCapacityTypes = getCapacityTypesAtClusterLevel();
// Generate Alerts for Zone Level capacities
for (final Zone zone : zones) {
for (final Short capacityType : dataCenterCapacityTypes) {
final List<SummedCapacity> capacity;
capacity = _capacityDao.findCapacityBy(capacityType.intValue(), zone.getId(), null, null);
if (capacityType == Capacity.CAPACITY_TYPE_SECONDARY_STORAGE) {
capacity.add(getUsedStats(capacityType, zone.getId(), null, null));
}
if (capacity == null || capacity.size() == 0) {
continue;
}
final double totalCapacity = capacity.get(0).getTotalCapacity();
final double usedCapacity = capacity.get(0).getUsedCapacity();
if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
generateEmailAlert(zone, null, null, totalCapacity, usedCapacity, capacityType);
}
}
}
// Generate Alerts for Pod Level capacities
for (final HostPodVO pod : podList) {
for (final Short capacityType : podCapacityTypes) {
final List<SummedCapacity> capacity = _capacityDao.findCapacityBy(capacityType.intValue(), pod.getDataCenterId(), pod.getId(), null);
if (capacity == null || capacity.size() == 0) {
continue;
}
final double totalCapacity = capacity.get(0).getTotalCapacity();
final double usedCapacity = capacity.get(0).getUsedCapacity();
if (totalCapacity != 0 && usedCapacity / totalCapacity > _capacityTypeThresholdMap.get(capacityType)) {
generateEmailAlert(zoneRepository.findById(pod.getDataCenterId()).orElse(null), pod, null, totalCapacity, usedCapacity, capacityType);
}
}
}
// Generate Alerts for Cluster Level capacities
for (final ClusterVO cluster : clusterList) {
for (final Short capacityType : clusterCapacityTypes) {
final List<SummedCapacity> capacity;
capacity = _capacityDao.findCapacityBy(capacityType.intValue(), cluster.getDataCenterId(), null, cluster.getId());
// cpu and memory allocated capacity notification threshold can be defined at cluster level, so getting the value if they are defined at cluster level
final double threshold;
switch(capacityType) {
case Capacity.CAPACITY_TYPE_STORAGE:
capacity.add(getUsedStats(capacityType, cluster.getDataCenterId(), cluster.getPodId(), cluster.getId()));
threshold = StorageCapacityThreshold.valueIn(cluster.getId());
break;
case Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED:
threshold = StorageAllocatedCapacityThreshold.valueIn(cluster.getId());
break;
case Capacity.CAPACITY_TYPE_CPU:
threshold = CPUCapacityThreshold.valueIn(cluster.getId());
break;
case Capacity.CAPACITY_TYPE_MEMORY:
threshold = MemoryCapacityThreshold.valueIn(cluster.getId());
break;
default:
threshold = _capacityTypeThresholdMap.get(capacityType);
}
if (capacity == null || capacity.size() == 0) {
continue;
}
final double totalCapacity = capacity.get(0).getTotalCapacity();
final double usedCapacity = capacity.get(0).getUsedCapacity() + capacity.get(0).getReservedCapacity();
if (totalCapacity != 0 && usedCapacity / totalCapacity > threshold) {
generateEmailAlert(zoneRepository.findById(cluster.getDataCenterId()).orElse(null), ApiDBUtils.findPodById(cluster.getPodId()), cluster, totalCapacity, usedCapacity, capacityType);
}
}
}
}
use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.
the class AlertManagerImpl method recalculateCapacity.
@Override
public void recalculateCapacity() {
if (s_logger.isDebugEnabled()) {
s_logger.debug("recalculating system capacity");
s_logger.debug("Executing cpu/ram capacity update");
}
// Calculate CPU and RAM capacities
// get all hosts...even if they are not in 'UP' state
final List<HostVO> hosts = _resourceMgr.listAllNotInMaintenanceHostsInOneZone(HostType.Routing, null);
if (hosts != null) {
for (final HostVO host : hosts) {
_capacityMgr.updateCapacityForHost(host);
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Done executing cpu/ram capacity update");
s_logger.debug("Executing storage capacity update");
}
// Calculate storage pool capacity
final List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
for (final StoragePoolVO pool : storagePools) {
final long disk = _capacityMgr.getAllocatedPoolCapacity(pool, null);
if (pool.isShared()) {
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED, disk);
} else {
_storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, disk);
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Done executing storage capacity update");
s_logger.debug("Executing capacity updates for public ip and Vlans");
}
final List<Zone> zones = zoneRepository.findByRemovedIsNull();
for (final Zone zone : zones) {
final long zoneId = zone.getId();
// Calculate new Public IP capacity for Virtual Network
if (zone.getNetworkType() == NetworkType.Advanced) {
createOrUpdateIpCapacity(zoneId, null, Capacity.CAPACITY_TYPE_VIRTUAL_NETWORK_PUBLIC_IP, zone.getAllocationState());
}
// Calculate new Public IP capacity for Direct Attached Network
createOrUpdateIpCapacity(zoneId, null, Capacity.CAPACITY_TYPE_DIRECT_ATTACHED_PUBLIC_IP, zone.getAllocationState());
if (zone.getNetworkType() == NetworkType.Advanced) {
// Calculate VLAN's capacity
createOrUpdateVlanCapacity(zoneId, zone.getAllocationState());
}
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Done capacity updates for public ip and Vlans");
s_logger.debug("Executing capacity updates for private ip");
}
// Calculate new Private IP capacity
final List<HostPodVO> pods = _podDao.listAll();
for (final HostPodVO pod : pods) {
final long podId = pod.getId();
final long dcId = pod.getDataCenterId();
createOrUpdateIpCapacity(dcId, podId, Capacity.CAPACITY_TYPE_PRIVATE_IP, _configMgr.findPodAllocationState(pod));
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Done executing capacity updates for private ip");
s_logger.debug("Done recalculating system capacity");
}
}
use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.
the class ConsoleProxyAlertAdapter method onProxyAlert.
public void onProxyAlert(final Object sender, final ConsoleProxyAlertEventArgs args) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("received console proxy alert");
}
final Zone zone = zoneRepository.findById(args.getZoneId()).orElse(null);
ConsoleProxyVO proxy = args.getProxy();
// FIXME - Proxy can be null in case of creation failure. Have a better fix than checking for != 0
if (proxy == null && args.getProxyId() != 0) {
proxy = _consoleProxyDao.findById(args.getProxyId());
}
if (proxy == null && args.getType() != ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE) {
throw new CloudRuntimeException("Invalid alert arguments, proxy must be set");
}
switch(args.getType()) {
case ConsoleProxyAlertEventArgs.PROXY_CREATED:
if (s_logger.isDebugEnabled()) {
s_logger.debug("New console proxy created, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress());
}
break;
case ConsoleProxyAlertEventArgs.PROXY_UP:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy is up, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress());
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy up in zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy up (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_DOWN:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy is down, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy down in zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy down (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_REBOOTED:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy is rebooted, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy rebooted in zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy rebooted (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy creation failure, zone: " + zone.getName());
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), null, "Console proxy creation failure. zone: " + zone.getName() + ", error details: " + args.getMessage(), "Console proxy creation failure (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_START_FAILURE:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy startup failure, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy startup failure. zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()) + ", error details: " + args.getMessage(), "Console proxy startup failure (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_FIREWALL_ALERT:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy firewall alert, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()));
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_CONSOLE_PROXY, args.getZoneId(), proxy.getPodIdToDeployIn(), "Failed to open console proxy firewall port. zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + (proxy.getPrivateIpAddress() == null ? "N/A" : proxy.getPrivateIpAddress()), "Console proxy alert (zone " + zone.getName() + ")");
break;
case ConsoleProxyAlertEventArgs.PROXY_STORAGE_ALERT:
if (s_logger.isDebugEnabled()) {
s_logger.debug("Console proxy storage alert, zone: " + zone.getName() + ", proxy: " + proxy.getHostName() + ", public IP: " + proxy.getPublicIpAddress() + ", private IP: " + proxy.getPrivateIpAddress() + ", message: " + args.getMessage());
}
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_STORAGE_MISC, args.getZoneId(), proxy.getPodIdToDeployIn(), "Console proxy storage issue. zone: " + zone.getName() + ", message: " + args.getMessage(), "Console proxy alert (zone " + zone.getName() + ")");
break;
}
}
use of com.cloud.db.model.Zone in project cosmic by MissionCriticalCloud.
the class VmWorkMigrate method getDeployDestination.
public DeployDestination getDeployDestination() {
final Zone zone = zoneId != null ? s_zoneRepository.findById(zoneId).orElse(null) : null;
final Pod pod = podId != null ? s_entityMgr.findById(Pod.class, podId) : null;
final Cluster cluster = clusterId != null ? s_entityMgr.findById(Cluster.class, clusterId) : null;
final Host host = hostId != null ? s_entityMgr.findById(Host.class, hostId) : null;
Map<Volume, StoragePool> vols = null;
if (storage != null) {
vols = new HashMap<>(storage.size());
for (final Map.Entry<String, String> entry : storage.entrySet()) {
vols.put(s_entityMgr.findByUuid(Volume.class, entry.getKey()), s_entityMgr.findByUuid(StoragePool.class, entry.getValue()));
}
}
final DeployDestination dest = new DeployDestination(zone, pod, cluster, host, vols);
return dest;
}
Aggregations