mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixing events for async jobs so that there's a scheduled event recorded with appropriate type/description whenever the API framework schedules the async command to run. A few miscellaneous fixes as well uncovered during regression testing (router response was not parsed correctly by UI, etc.)
This commit is contained in:
parent
24bd6a39e6
commit
9c593352d0
@ -29,7 +29,7 @@ public class EventTypes {
|
|||||||
public static final String EVENT_VM_ENABLE_HA = "VM.ENABLEHA";
|
public static final String EVENT_VM_ENABLE_HA = "VM.ENABLEHA";
|
||||||
public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
|
public static final String EVENT_VM_UPGRADE = "VM.UPGRADE";
|
||||||
public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
|
public static final String EVENT_VM_RESETPASSWORD = "VM.RESETPASSWORD";
|
||||||
|
|
||||||
// Domain Router
|
// Domain Router
|
||||||
public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
|
public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
|
||||||
public static final String EVENT_ROUTER_DESTROY = "ROUTER.DESTROY";
|
public static final String EVENT_ROUTER_DESTROY = "ROUTER.DESTROY";
|
||||||
@ -37,7 +37,7 @@ public class EventTypes {
|
|||||||
public static final String EVENT_ROUTER_STOP = "ROUTER.STOP";
|
public static final String EVENT_ROUTER_STOP = "ROUTER.STOP";
|
||||||
public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
|
public static final String EVENT_ROUTER_REBOOT = "ROUTER.REBOOT";
|
||||||
public static final String EVENT_ROUTER_HA = "ROUTER.HA";
|
public static final String EVENT_ROUTER_HA = "ROUTER.HA";
|
||||||
|
|
||||||
// Console proxy
|
// Console proxy
|
||||||
public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
|
public static final String EVENT_PROXY_CREATE = "PROXY.CREATE";
|
||||||
public static final String EVENT_PROXY_DESTROY = "PROXY.DESTROY";
|
public static final String EVENT_PROXY_DESTROY = "PROXY.DESTROY";
|
||||||
@ -45,32 +45,41 @@ public class EventTypes {
|
|||||||
public static final String EVENT_PROXY_STOP = "PROXY.STOP";
|
public static final String EVENT_PROXY_STOP = "PROXY.STOP";
|
||||||
public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
|
public static final String EVENT_PROXY_REBOOT = "PROXY.REBOOT";
|
||||||
public static final String EVENT_PROXY_HA = "PROXY.HA";
|
public static final String EVENT_PROXY_HA = "PROXY.HA";
|
||||||
|
|
||||||
// VNC Console Events
|
// VNC Console Events
|
||||||
public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
|
public static final String EVENT_VNC_CONNECT = "VNC.CONNECT";
|
||||||
public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT";
|
public static final String EVENT_VNC_DISCONNECT = "VNC.DISCONNECT";
|
||||||
|
|
||||||
// Network Events
|
// Network Events
|
||||||
public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN";
|
public static final String EVENT_NET_IP_ASSIGN = "NET.IPASSIGN";
|
||||||
public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE";
|
public static final String EVENT_NET_IP_RELEASE = "NET.IPRELEASE";
|
||||||
public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
|
public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
|
||||||
public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
|
public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
|
||||||
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";
|
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";
|
||||||
|
|
||||||
// Security Groups
|
// Security Groups
|
||||||
public static final String EVENT_PORT_FORWARDING_SERVICE_APPLY = "PF.SERVICE.APPLY";
|
public static final String EVENT_PORT_FORWARDING_SERVICE_APPLY = "PF.SERVICE.APPLY";
|
||||||
public static final String EVENT_PORT_FORWARDING_SERVICE_DELETE = "PF.SERVICE.DELETE";
|
public static final String EVENT_PORT_FORWARDING_SERVICE_DELETE = "PF.SERVICE.DELETE";
|
||||||
public static final String EVENT_PORT_FORWARDING_SERVICE_REMOVE = "PF.SERVICE.REMOVE";
|
public static final String EVENT_PORT_FORWARDING_SERVICE_REMOVE = "PF.SERVICE.REMOVE";
|
||||||
public static final String EVENT_LOAD_BALANCER_CREATE = "LB.CREATE";
|
|
||||||
|
// Load Balancers
|
||||||
|
public static final String EVENT_ASSIGN_TO_LOAD_BALANCER_RULE = "LB.ASSIGN.TO.RULE";
|
||||||
|
public static final String EVENT_REMOVE_FROM_LOAD_BALANCER_RULE = "LB.REMOVE.FROM.RULE";
|
||||||
|
public static final String EVENT_LOAD_BALANCER_CREATE = "LB.CREATE";
|
||||||
public static final String EVENT_LOAD_BALANCER_DELETE = "LB.DELETE";
|
public static final String EVENT_LOAD_BALANCER_DELETE = "LB.DELETE";
|
||||||
|
public static final String EVENT_LOAD_BALANCER_UPDATE = "LB.UPDATE";
|
||||||
|
|
||||||
|
// Account events
|
||||||
|
public static final String EVENT_ACCOUNT_DISABLE = "ACCOUNT.DISABLE";
|
||||||
|
|
||||||
// UserVO Events
|
// UserVO Events
|
||||||
public static final String EVENT_USER_LOGIN = "USER.LOGIN";
|
public static final String EVENT_USER_LOGIN = "USER.LOGIN";
|
||||||
public static final String EVENT_USER_LOGOUT = "USER.LOGOUT";
|
public static final String EVENT_USER_LOGOUT = "USER.LOGOUT";
|
||||||
public static final String EVENT_USER_CREATE = "USER.CREATE";
|
public static final String EVENT_USER_CREATE = "USER.CREATE";
|
||||||
public static final String EVENT_USER_DELETE = "USER.DELETE";
|
public static final String EVENT_USER_DELETE = "USER.DELETE";
|
||||||
|
public static final String EVENT_USER_DISABLE = "USER.DISABLE";
|
||||||
public static final String EVENT_USER_UPDATE = "USER.UPDATE";
|
public static final String EVENT_USER_UPDATE = "USER.UPDATE";
|
||||||
|
|
||||||
//Template Events
|
//Template Events
|
||||||
public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE";
|
public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE";
|
||||||
public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE";
|
public static final String EVENT_TEMPLATE_DELETE = "TEMPLATE.DELETE";
|
||||||
@ -79,35 +88,37 @@ public class EventTypes {
|
|||||||
public static final String EVENT_TEMPLATE_DOWNLOAD_SUCCESS = "TEMPLATE.DOWNLOAD.SUCCESS";
|
public static final String EVENT_TEMPLATE_DOWNLOAD_SUCCESS = "TEMPLATE.DOWNLOAD.SUCCESS";
|
||||||
public static final String EVENT_TEMPLATE_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED";
|
public static final String EVENT_TEMPLATE_DOWNLOAD_FAILED = "TEMPLATE.DOWNLOAD.FAILED";
|
||||||
public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY";
|
public static final String EVENT_TEMPLATE_COPY = "TEMPLATE.COPY";
|
||||||
|
public static final String EVENT_TEMPLATE_EXTRACT = "TEMPLATE.EXTRACT";
|
||||||
public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD";
|
public static final String EVENT_TEMPLATE_UPLOAD = "TEMPLATE.UPLOAD";
|
||||||
|
|
||||||
// Volume Events
|
// Volume Events
|
||||||
public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
|
public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
|
||||||
public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
|
public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
|
||||||
public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
|
public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
|
||||||
public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
|
public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
|
||||||
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
|
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
|
||||||
|
|
||||||
// Domains
|
// Domains
|
||||||
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
|
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
|
||||||
public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE";
|
public static final String EVENT_DOMAIN_DELETE = "DOMAIN.DELETE";
|
||||||
public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE";
|
public static final String EVENT_DOMAIN_UPDATE = "DOMAIN.UPDATE";
|
||||||
|
|
||||||
// Snapshots
|
// Snapshots
|
||||||
public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
|
public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
|
||||||
public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE";
|
public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE";
|
||||||
public static final String EVENT_SNAPSHOT_POLICY_CREATE = "SNAPSHOTPOLICY.CREATE";
|
public static final String EVENT_SNAPSHOT_POLICY_CREATE = "SNAPSHOTPOLICY.CREATE";
|
||||||
public static final String EVENT_SNAPSHOT_POLICY_UPDATE = "SNAPSHOTPOLICY.UPDATE";
|
public static final String EVENT_SNAPSHOT_POLICY_UPDATE = "SNAPSHOTPOLICY.UPDATE";
|
||||||
public static final String EVENT_SNAPSHOT_POLICY_DELETE = "SNAPSHOTPOLICY.DELETE";
|
public static final String EVENT_SNAPSHOT_POLICY_DELETE = "SNAPSHOTPOLICY.DELETE";
|
||||||
|
|
||||||
// ISO
|
// ISO
|
||||||
public static final String EVENT_ISO_CREATE = "ISO.CREATE";
|
public static final String EVENT_ISO_CREATE = "ISO.CREATE";
|
||||||
public static final String EVENT_ISO_DELETE = "ISO.DELETE";
|
public static final String EVENT_ISO_DELETE = "ISO.DELETE";
|
||||||
public static final String EVENT_ISO_COPY = "ISO.COPY";
|
public static final String EVENT_ISO_COPY = "ISO.COPY";
|
||||||
public static final String EVENT_ISO_ATTACH = "ISO.ATTACH";
|
public static final String EVENT_ISO_ATTACH = "ISO.ATTACH";
|
||||||
public static final String EVENT_ISO_DETACH = "ISO.DETACH";
|
public static final String EVENT_ISO_DETACH = "ISO.DETACH";
|
||||||
|
public static final String EVENT_ISO_EXTRACT = "ISO.EXTRACT";
|
||||||
public static final String EVENT_ISO_UPLOAD = "ISO.UPLOAD";
|
public static final String EVENT_ISO_UPLOAD = "ISO.UPLOAD";
|
||||||
|
|
||||||
//SSVM
|
//SSVM
|
||||||
public static final String EVENT_SSVM_CREATE = "SSVM.CREATE";
|
public static final String EVENT_SSVM_CREATE = "SSVM.CREATE";
|
||||||
public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY";
|
public static final String EVENT_SSVM_DESTROY = "SSVM.DESTROY";
|
||||||
@ -115,32 +126,44 @@ public class EventTypes {
|
|||||||
public static final String EVENT_SSVM_STOP = "SSVM.STOP";
|
public static final String EVENT_SSVM_STOP = "SSVM.STOP";
|
||||||
public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
|
public static final String EVENT_SSVM_REBOOT = "SSVM.REBOOT";
|
||||||
public static final String EVENT_SSVM_HA = "SSVM.HA";
|
public static final String EVENT_SSVM_HA = "SSVM.HA";
|
||||||
|
|
||||||
// Service Offerings
|
// Service Offerings
|
||||||
public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
|
public static final String EVENT_SERVICE_OFFERING_CREATE = "SERVICE.OFFERING.CREATE";
|
||||||
public static final String EVENT_SERVICE_OFFERING_EDIT = "SERVICE.OFFERING.EDIT";
|
public static final String EVENT_SERVICE_OFFERING_EDIT = "SERVICE.OFFERING.EDIT";
|
||||||
public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE";
|
public static final String EVENT_SERVICE_OFFERING_DELETE = "SERVICE.OFFERING.DELETE";
|
||||||
|
|
||||||
// Disk Offerings
|
// Disk Offerings
|
||||||
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
|
public static final String EVENT_DISK_OFFERING_CREATE = "DISK.OFFERING.CREATE";
|
||||||
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
|
public static final String EVENT_DISK_OFFERING_EDIT = "DISK.OFFERING.EDIT";
|
||||||
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
|
public static final String EVENT_DISK_OFFERING_DELETE = "DISK.OFFERING.DELETE";
|
||||||
|
|
||||||
// Pods
|
// Pods
|
||||||
public static final String EVENT_POD_CREATE = "POD.CREATE";
|
public static final String EVENT_POD_CREATE = "POD.CREATE";
|
||||||
public static final String EVENT_POD_EDIT = "POD.EDIT";
|
public static final String EVENT_POD_EDIT = "POD.EDIT";
|
||||||
public static final String EVENT_POD_DELETE = "POD.DELETE";
|
public static final String EVENT_POD_DELETE = "POD.DELETE";
|
||||||
|
|
||||||
// Zones
|
// Zones
|
||||||
public static final String EVENT_ZONE_CREATE = "ZONE.CREATE";
|
public static final String EVENT_ZONE_CREATE = "ZONE.CREATE";
|
||||||
public static final String EVENT_ZONE_EDIT = "ZONE.EDIT";
|
public static final String EVENT_ZONE_EDIT = "ZONE.EDIT";
|
||||||
public static final String EVENT_ZONE_DELETE = "ZONE.DELETE";
|
public static final String EVENT_ZONE_DELETE = "ZONE.DELETE";
|
||||||
|
|
||||||
// VLANs/IP ranges
|
// VLANs/IP ranges
|
||||||
public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
|
public static final String EVENT_VLAN_IP_RANGE_CREATE = "VLAN.IP.RANGE.CREATE";
|
||||||
public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
|
public static final String EVENT_VLAN_IP_RANGE_DELETE = "VLAN.IP.RANGE.DELETE";
|
||||||
|
|
||||||
// Configuration Table
|
// Configuration Table
|
||||||
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
|
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
|
||||||
|
|
||||||
|
// Network Groups
|
||||||
|
public static final String EVENT_NETWORK_GROUP_AUTHORIZE_INGRESS = "NG.AUTH.INGRESS";
|
||||||
|
public static final String EVENT_NETWORK_GROUP_REVOKE_INGRESS = "NG.REVOKE.INGRESS";
|
||||||
|
|
||||||
|
// Host
|
||||||
|
public static final String EVENT_HOST_RECONNECT = "HOST.RECONNECT";
|
||||||
|
|
||||||
|
// Maintenance
|
||||||
|
public static final String EVENT_MAINTENANCE_CANCEL = "MAINT.CANCEL";
|
||||||
|
public static final String EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE = "MAINT.CANCEL.PS";
|
||||||
|
public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE";
|
||||||
|
public static final String EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE = "MAINT.PREPARE.PS";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,13 @@ import com.cloud.host.HostStats;
|
|||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.dao.HostDao;
|
import com.cloud.host.dao.HostDao;
|
||||||
import com.cloud.network.IPAddressVO;
|
import com.cloud.network.IPAddressVO;
|
||||||
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
import com.cloud.network.NetworkRuleConfigVO;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
import com.cloud.network.dao.IPAddressDao;
|
||||||
|
import com.cloud.network.dao.LoadBalancerDao;
|
||||||
|
import com.cloud.network.dao.NetworkRuleConfigDao;
|
||||||
|
import com.cloud.network.dao.SecurityGroupDao;
|
||||||
import com.cloud.network.security.NetworkGroupManager;
|
import com.cloud.network.security.NetworkGroupManager;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.server.Criteria;
|
import com.cloud.server.Criteria;
|
||||||
@ -63,11 +69,13 @@ import com.cloud.user.dao.UserStatisticsDao;
|
|||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.utils.DateUtil;
|
import com.cloud.utils.DateUtil;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
|
import com.cloud.vm.DomainRouterVO;
|
||||||
import com.cloud.vm.InstanceGroupVO;
|
import com.cloud.vm.InstanceGroupVO;
|
||||||
import com.cloud.vm.UserVmManager;
|
import com.cloud.vm.UserVmManager;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
import com.cloud.vm.VmStats;
|
import com.cloud.vm.VmStats;
|
||||||
|
import com.cloud.vm.dao.DomainRouterDao;
|
||||||
import com.cloud.vm.dao.UserVmDao;
|
import com.cloud.vm.dao.UserVmDao;
|
||||||
|
|
||||||
public class ApiDBUtils {
|
public class ApiDBUtils {
|
||||||
@ -86,11 +94,15 @@ public class ApiDBUtils {
|
|||||||
private static ClusterDao _clusterDao;
|
private static ClusterDao _clusterDao;
|
||||||
private static DiskOfferingDao _diskOfferingDao;
|
private static DiskOfferingDao _diskOfferingDao;
|
||||||
private static DomainDao _domainDao;
|
private static DomainDao _domainDao;
|
||||||
|
private static DomainRouterDao _domainRouterDao;
|
||||||
private static GuestOSDao _guestOSDao;
|
private static GuestOSDao _guestOSDao;
|
||||||
private static GuestOSCategoryDao _guestOSCategoryDao;
|
private static GuestOSCategoryDao _guestOSCategoryDao;
|
||||||
private static HostDao _hostDao;
|
private static HostDao _hostDao;
|
||||||
private static IPAddressDao _ipAddressDao;
|
private static IPAddressDao _ipAddressDao;
|
||||||
|
private static LoadBalancerDao _loadBalancerDao;
|
||||||
|
private static NetworkRuleConfigDao _networkRuleConfigDao;
|
||||||
private static HostPodDao _podDao;
|
private static HostPodDao _podDao;
|
||||||
|
private static SecurityGroupDao _securityGroupDao;
|
||||||
private static ServiceOfferingDao _serviceOfferingDao;
|
private static ServiceOfferingDao _serviceOfferingDao;
|
||||||
private static SnapshotDao _snapshotDao;
|
private static SnapshotDao _snapshotDao;
|
||||||
private static StoragePoolDao _storagePoolDao;
|
private static StoragePoolDao _storagePoolDao;
|
||||||
@ -120,11 +132,15 @@ public class ApiDBUtils {
|
|||||||
_clusterDao = locator.getDao(ClusterDao.class);
|
_clusterDao = locator.getDao(ClusterDao.class);
|
||||||
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
_diskOfferingDao = locator.getDao(DiskOfferingDao.class);
|
||||||
_domainDao = locator.getDao(DomainDao.class);
|
_domainDao = locator.getDao(DomainDao.class);
|
||||||
|
_domainRouterDao = locator.getDao(DomainRouterDao.class);
|
||||||
_guestOSDao = locator.getDao(GuestOSDao.class);
|
_guestOSDao = locator.getDao(GuestOSDao.class);
|
||||||
_guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
|
_guestOSCategoryDao = locator.getDao(GuestOSCategoryDao.class);
|
||||||
_hostDao = locator.getDao(HostDao.class);
|
_hostDao = locator.getDao(HostDao.class);
|
||||||
_ipAddressDao = locator.getDao(IPAddressDao.class);
|
_ipAddressDao = locator.getDao(IPAddressDao.class);
|
||||||
|
_loadBalancerDao = locator.getDao(LoadBalancerDao.class);
|
||||||
|
_networkRuleConfigDao = locator.getDao(NetworkRuleConfigDao.class);
|
||||||
_podDao = locator.getDao(HostPodDao.class);
|
_podDao = locator.getDao(HostPodDao.class);
|
||||||
|
_securityGroupDao = locator.getDao(SecurityGroupDao.class);
|
||||||
_serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
|
_serviceOfferingDao = locator.getDao(ServiceOfferingDao.class);
|
||||||
_snapshotDao = locator.getDao(SnapshotDao.class);
|
_snapshotDao = locator.getDao(SnapshotDao.class);
|
||||||
_storagePoolDao = locator.getDao(StoragePoolDao.class);
|
_storagePoolDao = locator.getDao(StoragePoolDao.class);
|
||||||
@ -258,6 +274,10 @@ public class ApiDBUtils {
|
|||||||
return _accountDao.findById(accountId);
|
return _accountDao.findById(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Account findAccountByNameDomain(String accountName, Long domainId) {
|
||||||
|
return _accountDao.findActiveAccount(accountName, domainId);
|
||||||
|
}
|
||||||
|
|
||||||
public static ClusterVO findClusterById(long clusterId) {
|
public static ClusterVO findClusterById(long clusterId) {
|
||||||
return _clusterDao.findById(clusterId);
|
return _clusterDao.findById(clusterId);
|
||||||
}
|
}
|
||||||
@ -270,6 +290,10 @@ public class ApiDBUtils {
|
|||||||
return _domainDao.findById(domainId);
|
return _domainDao.findById(domainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DomainRouterVO findDomainRouterById(Long routerId) {
|
||||||
|
return _domainRouterDao.findById(routerId);
|
||||||
|
}
|
||||||
|
|
||||||
public static GuestOS findGuestOSById(Long id) {
|
public static GuestOS findGuestOSById(Long id) {
|
||||||
return _guestOSDao.findById(id);
|
return _guestOSDao.findById(id);
|
||||||
}
|
}
|
||||||
@ -292,10 +316,22 @@ public class ApiDBUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LoadBalancerVO findLoadBalancerById(Long loadBalancerId) {
|
||||||
|
return _loadBalancerDao.findById(loadBalancerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetworkRuleConfigVO findNetworkRuleById(Long ruleId) {
|
||||||
|
return _networkRuleConfigDao.findById(ruleId);
|
||||||
|
}
|
||||||
|
|
||||||
public static HostPodVO findPodById(Long podId) {
|
public static HostPodVO findPodById(Long podId) {
|
||||||
return _podDao.findById(podId);
|
return _podDao.findById(podId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SecurityGroupVO findPortForwardingServiceById(Long securityGroupId) {
|
||||||
|
return _securityGroupDao.findById(securityGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
public static ServiceOffering findServiceOfferingById(Long serviceOfferingId) {
|
public static ServiceOffering findServiceOfferingById(Long serviceOfferingId) {
|
||||||
return _serviceOfferingDao.findById(serviceOfferingId);
|
return _serviceOfferingDao.findById(serviceOfferingId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -231,7 +231,7 @@ public class ApiDispatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupParameters(BaseCmd cmd, Map<String, String> params) {
|
public static void setupParameters(BaseCmd cmd, Map<String, String> params) {
|
||||||
Map<String, Object> unpackedParams = cmd.unpackParams(params);
|
Map<String, Object> unpackedParams = cmd.unpackParams(params);
|
||||||
Field[] fields = cmd.getClass().getDeclaredFields();
|
Field[] fields = cmd.getClass().getDeclaredFields();
|
||||||
Class<?> superClass = cmd.getClass().getSuperclass();
|
Class<?> superClass = cmd.getClass().getSuperclass();
|
||||||
@ -282,7 +282,7 @@ public class ApiDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
private void setFieldValue(Field field, BaseCmd cmdObj, Object paramObj, Parameter annotation) throws IllegalArgumentException, ParseException {
|
private static void setFieldValue(Field field, BaseCmd cmdObj, Object paramObj, Parameter annotation) throws IllegalArgumentException, ParseException {
|
||||||
try {
|
try {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
CommandType fieldType = annotation.type();
|
CommandType fieldType = annotation.type();
|
||||||
|
|||||||
@ -84,6 +84,7 @@ import com.cloud.configuration.ConfigurationVO;
|
|||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.domain.Domain;
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.domain.DomainVO;
|
import com.cloud.domain.DomainVO;
|
||||||
|
import com.cloud.event.EventUtils;
|
||||||
import com.cloud.exception.CloudAuthenticationException;
|
import com.cloud.exception.CloudAuthenticationException;
|
||||||
import com.cloud.maid.StackMaid;
|
import com.cloud.maid.StackMaid;
|
||||||
import com.cloud.serializer.GsonHelper;
|
import com.cloud.serializer.GsonHelper;
|
||||||
@ -99,7 +100,6 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
|
|||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.encoding.Base64;
|
import com.cloud.utils.encoding.Base64;
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
public class ApiServer implements HttpRequestHandler {
|
public class ApiServer implements HttpRequestHandler {
|
||||||
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
|
||||||
@ -351,10 +351,11 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
objectId = _dispatcher.dispatchCreateCmd(createCmd, params);
|
objectId = _dispatcher.dispatchCreateCmd(createCmd, params);
|
||||||
createCmd.setId(objectId);
|
createCmd.setId(objectId);
|
||||||
params.put("id", objectId.toString());
|
params.put("id", objectId.toString());
|
||||||
|
} else {
|
||||||
|
ApiDispatcher.setupParameters(cmdObj, params);
|
||||||
}
|
}
|
||||||
BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
|
|
||||||
|
|
||||||
Gson gson = GsonHelper.getBuilder().create();
|
BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmdObj;
|
||||||
|
|
||||||
UserContext ctx = UserContext.current();
|
UserContext ctx = UserContext.current();
|
||||||
Long userId = ctx.getUserId();
|
Long userId = ctx.getUserId();
|
||||||
@ -366,6 +367,14 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
params.put("ctxAccountId", String.valueOf(account.getId()));
|
params.put("ctxAccountId", String.valueOf(account.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// save the scheduled event
|
||||||
|
Long eventId = EventUtils.saveScheduledEvent((userId == null) ? User.UID_SYSTEM : userId, asyncCmd.getAccountId(),
|
||||||
|
asyncCmd.getEventType(), asyncCmd.getEventDescription());
|
||||||
|
|
||||||
|
if (eventId != null) {
|
||||||
|
params.put("starteventid", eventId.toString());
|
||||||
|
}
|
||||||
|
|
||||||
AsyncJobVO job = new AsyncJobVO();
|
AsyncJobVO job = new AsyncJobVO();
|
||||||
job.setUserId(userId);
|
job.setUserId(userId);
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
@ -377,7 +386,8 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
job.setAccountId(1L);
|
job.setAccountId(1L);
|
||||||
}
|
}
|
||||||
job.setCmd(cmdObj.getClass().getName());
|
job.setCmd(cmdObj.getClass().getName());
|
||||||
job.setCmdInfo(gson.toJson(params));
|
job.setCmdInfo(GsonHelper.getBuilder().create().toJson(params));
|
||||||
|
|
||||||
long jobId = _asyncMgr.submitAsyncJob(job);
|
long jobId = _asyncMgr.submitAsyncJob(job);
|
||||||
if (objectId != null) {
|
if (objectId != null) {
|
||||||
return ((BaseAsyncCreateCmd)asyncCmd).getResponse(jobId, objectId);
|
return ((BaseAsyncCreateCmd)asyncCmd).getResponse(jobId, objectId);
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under the GNU General Public License v3 or later.
|
||||||
|
*
|
||||||
|
* It is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package com.cloud.api;
|
package com.cloud.api;
|
||||||
|
|
||||||
import com.cloud.api.response.AsyncJobResponse;
|
import com.cloud.api.response.AsyncJobResponse;
|
||||||
@ -13,8 +30,33 @@ import com.cloud.async.AsyncJobVO;
|
|||||||
public abstract class BaseAsyncCmd extends BaseCmd {
|
public abstract class BaseAsyncCmd extends BaseCmd {
|
||||||
private AsyncJobManager _asyncJobMgr = null;
|
private AsyncJobManager _asyncJobMgr = null;
|
||||||
private AsyncJobVO _job = null;
|
private AsyncJobVO _job = null;
|
||||||
|
|
||||||
|
@Parameter(name="starteventid", type=CommandType.LONG)
|
||||||
private Long startEventId;
|
private Long startEventId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For async commands the API framework needs to know the owner of the object being acted upon. This method is
|
||||||
|
* used to determine that information.
|
||||||
|
* @return the id of the account that owns the object being acted upon
|
||||||
|
*/
|
||||||
|
public abstract long getAccountId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For proper tracking of async commands through the system, events must be generated when the command is
|
||||||
|
* scheduled, started, and completed. Commands should specify the type of event so that when the scheduled,
|
||||||
|
* started, and completed events are saved to the events table, they have the proper type information.
|
||||||
|
* @return a string representing the type of event, e.g. VM.START, VOLUME.CREATE.
|
||||||
|
*/
|
||||||
|
public abstract String getEventType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For proper tracking of async commands through the system, events must be generated when the command is
|
||||||
|
* scheduled, started, and completed. Commands should specify a description for these events so that when
|
||||||
|
* the scheduled, started, and completed events are saved to the events table, they have a meaningful description.
|
||||||
|
* @return a string representing a description of the event
|
||||||
|
*/
|
||||||
|
public abstract String getEventDescription();
|
||||||
|
|
||||||
public ResponseObject getResponse(long jobId) {
|
public ResponseObject getResponse(long jobId) {
|
||||||
AsyncJobResponse response = new AsyncJobResponse();
|
AsyncJobResponse response = new AsyncJobResponse();
|
||||||
response.setId(jobId);
|
response.setId(jobId);
|
||||||
|
|||||||
@ -21,11 +21,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="assignSecurityGroup", manager=Manager.ManagementServer)
|
@Implementation(method="assignSecurityGroup", manager=Manager.ManagementServer)
|
||||||
public class AssignPortForwardingServiceCmd extends BaseAsyncCmd {
|
public class AssignPortForwardingServiceCmd extends BaseAsyncCmd {
|
||||||
@ -80,6 +84,25 @@ public class AssignPortForwardingServiceCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
SecurityGroupVO sg = ApiDBUtils.findPortForwardingServiceById(getId());
|
||||||
|
if (sg == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return sg.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_PORT_FORWARDING_SERVICE_APPLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "applying port forwarding service for vm with id: " + getVirtualMachineId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -21,11 +21,15 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="assignToLoadBalancer", manager=Manager.NetworkManager)
|
@Implementation(method="assignToLoadBalancer", manager=Manager.NetworkManager)
|
||||||
public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
|
public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
|
||||||
@ -66,10 +70,30 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
LoadBalancerVO lb = ApiDBUtils.findLoadBalancerById(getLoadBalancerId());
|
||||||
|
if (lb == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return lb.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ASSIGN_TO_LOAD_BALANCER_RULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "applying port forwarding service for vm with id: " + getVirtualMachineId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
@ -26,6 +27,9 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="attachIso", manager=Manager.TemplateManager)
|
@Implementation(method="attachIso", manager=Manager.TemplateManager)
|
||||||
public class AttachIsoCmd extends BaseAsyncCmd {
|
public class AttachIsoCmd extends BaseAsyncCmd {
|
||||||
@ -66,6 +70,25 @@ public class AttachIsoCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VMTemplateVO iso = ApiDBUtils.findTemplateById(getId());
|
||||||
|
if (iso == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return iso.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ISO_ATTACH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -26,7 +26,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.VolumeResponse;
|
import com.cloud.api.response.VolumeResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="attachVolumeToVM", manager=Manager.UserVmManager)
|
@Implementation(method="attachVolumeToVM", manager=Manager.UserVmManager)
|
||||||
@ -74,6 +76,25 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VolumeVO volume = ApiDBUtils.findVolumeById(getId());
|
||||||
|
if (volume == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return volume.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VOLUME_ATTACH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public VolumeResponse getResponse() {
|
public VolumeResponse getResponse() {
|
||||||
VolumeVO volume = ApiDBUtils.findVolumeById(id);
|
VolumeVO volume = ApiDBUtils.findVolumeById(id);
|
||||||
|
|||||||
@ -19,18 +19,26 @@
|
|||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.IngressRuleResponse;
|
import com.cloud.api.response.IngressRuleResponse;
|
||||||
import com.cloud.api.response.ListResponse;
|
import com.cloud.api.response.ListResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.network.security.IngressRuleVO;
|
import com.cloud.network.security.IngressRuleVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
import com.cloud.utils.StringUtils;
|
||||||
|
|
||||||
@Implementation(method="authorizeNetworkGroupIngress", manager=Manager.NetworkGroupManager) @SuppressWarnings("rawtypes")
|
@Implementation(method="authorizeNetworkGroupIngress", manager=Manager.NetworkGroupManager) @SuppressWarnings("rawtypes")
|
||||||
public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
||||||
@ -134,6 +142,59 @@ public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
|||||||
return "networkgroup";
|
return "networkgroup";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if ((account == null) || isAdmin(account.getType())) {
|
||||||
|
if ((domainId != null) && (accountName != null)) {
|
||||||
|
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||||
|
if (userAccount != null) {
|
||||||
|
return userAccount.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NETWORK_GROUP_AUTHORIZE_INGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (getUserNetworkGroupList() != null) {
|
||||||
|
sb.append("group list(group/account): ");
|
||||||
|
Collection userGroupCollection = getUserNetworkGroupList().values();
|
||||||
|
Iterator iter = userGroupCollection.iterator();
|
||||||
|
|
||||||
|
HashMap userGroup = (HashMap)iter.next();
|
||||||
|
String group = (String)userGroup.get("group");
|
||||||
|
String authorizedAccountName = (String)userGroup.get("account");
|
||||||
|
sb.append(group + "/" + authorizedAccountName);
|
||||||
|
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
userGroup = (HashMap)iter.next();
|
||||||
|
group = (String)userGroup.get("group");
|
||||||
|
authorizedAccountName = (String)userGroup.get("account");
|
||||||
|
sb.append(", " + group + "/" + authorizedAccountName);
|
||||||
|
}
|
||||||
|
} else if (getCidrList() != null) {
|
||||||
|
sb.append("cidr list: ");
|
||||||
|
sb.append(StringUtils.join(getCidrList(), ", "));
|
||||||
|
} else {
|
||||||
|
sb.append("<error: no ingress parameters>");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "authorizing ingress to group: " + getNetworkGroupName() + " to " + sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public ListResponse<IngressRuleResponse> getResponse() {
|
public ListResponse<IngressRuleResponse> getResponse() {
|
||||||
List<IngressRuleVO> ingressRules = (List<IngressRuleVO>)getResponseObject();
|
List<IngressRuleVO> ingressRules = (List<IngressRuleVO>)getResponseObject();
|
||||||
|
|||||||
@ -33,12 +33,15 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.HostResponse;
|
import com.cloud.api.response.HostResponse;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.HostStats;
|
import com.cloud.host.HostStats;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.Status.Event;
|
import com.cloud.host.Status.Event;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.storage.GuestOSCategoryVO;
|
import com.cloud.storage.GuestOSCategoryVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
|
|
||||||
@Implementation(method="cancelMaintenance", manager=Manager.AgentManager)
|
@Implementation(method="cancelMaintenance", manager=Manager.AgentManager)
|
||||||
@ -68,6 +71,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
@ -76,6 +80,26 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
return "host";
|
return "host";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_MAINTENANCE_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "canceling maintenance for host: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public HostResponse getResponse() {
|
public HostResponse getResponse() {
|
||||||
HostVO host = (HostVO)getResponseObject();
|
HostVO host = (HostVO)getResponseObject();
|
||||||
|
|||||||
@ -27,8 +27,11 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.StoragePoolResponse;
|
import com.cloud.api.response.StoragePoolResponse;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.StoragePoolVO;
|
import com.cloud.storage.StoragePoolVO;
|
||||||
import com.cloud.storage.StorageStats;
|
import com.cloud.storage.StorageStats;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="cancelPrimaryStorageForMaintenance", manager=Manager.StorageManager)
|
@Implementation(method="cancelPrimaryStorageForMaintenance", manager=Manager.StorageManager)
|
||||||
public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
|
public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
|
||||||
@ -57,6 +60,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
@ -65,6 +69,26 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
return "primarystorage";
|
return "primarystorage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "canceling maintenance for primary storage pool: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public StoragePoolResponse getResponse() {
|
public StoragePoolResponse getResponse() {
|
||||||
StoragePoolVO primaryStorage = (StoragePoolVO)getResponseObject();
|
StoragePoolVO primaryStorage = (StoragePoolVO)getResponseObject();
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.TemplateResponse;
|
import com.cloud.api.response.TemplateResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.GuestOS;
|
import com.cloud.storage.GuestOS;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
@ -69,7 +70,6 @@ public class CopyIsoCmd extends BaseAsyncCmd {
|
|||||||
return sourceZoneId;
|
return sourceZoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -83,6 +83,27 @@ public class CopyIsoCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VMTemplateVO iso = ApiDBUtils.findTemplateById(getId());
|
||||||
|
if (iso != null) {
|
||||||
|
return iso.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ISO_COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "copying ISO: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public TemplateResponse getResponse() {
|
public TemplateResponse getResponse() {
|
||||||
TemplateResponse isoResponse = new TemplateResponse();
|
TemplateResponse isoResponse = new TemplateResponse();
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.TemplateResponse;
|
import com.cloud.api.response.TemplateResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.GuestOS;
|
import com.cloud.storage.GuestOS;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||||
@ -70,7 +71,6 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
|
|||||||
return sourceZoneId;
|
return sourceZoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -84,6 +84,27 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VMTemplateVO template = ApiDBUtils.findTemplateById(getId());
|
||||||
|
if (template != null) {
|
||||||
|
return template.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_TEMPLATE_COPY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public TemplateResponse getResponse() {
|
public TemplateResponse getResponse() {
|
||||||
TemplateResponse templateResponse = new TemplateResponse();
|
TemplateResponse templateResponse = new TemplateResponse();
|
||||||
|
|||||||
@ -20,11 +20,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCreateCmd;
|
import com.cloud.api.BaseAsyncCreateCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.PortForwardingServiceRuleResponse;
|
import com.cloud.api.response.PortForwardingServiceRuleResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.network.NetworkRuleConfigVO;
|
import com.cloud.network.NetworkRuleConfigVO;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(createMethod="createPortForwardingServiceRule", method="applyPortForwardingServiceRule")
|
@Implementation(createMethod="createPortForwardingServiceRule", method="applyPortForwardingServiceRule")
|
||||||
public class CreatePortForwardingServiceRuleCmd extends BaseAsyncCreateCmd {
|
public class CreatePortForwardingServiceRuleCmd extends BaseAsyncCreateCmd {
|
||||||
@ -83,6 +87,28 @@ public class CreatePortForwardingServiceRuleCmd extends BaseAsyncCreateCmd {
|
|||||||
return "portforwardingservicerule";
|
return "portforwardingservicerule";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
SecurityGroupVO portForwardingService = ApiDBUtils.findPortForwardingServiceById(getPortForwardingServiceId());
|
||||||
|
if (portForwardingService != null) {
|
||||||
|
return portForwardingService.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NET_RULE_ADD; // FIXME: Add a new event?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "creating port forwarding rule on service: " + getPortForwardingServiceId() + ", public port: " + getPublicPort() +
|
||||||
|
", priv port: " + getPrivatePort() + ", protocol: " + ((getProtocol() == null) ? "TCP" : getProtocol());
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public PortForwardingServiceRuleResponse getResponse() {
|
public PortForwardingServiceRuleResponse getResponse() {
|
||||||
NetworkRuleConfigVO netRule = (NetworkRuleConfigVO)getResponseObject();
|
NetworkRuleConfigVO netRule = (NetworkRuleConfigVO)getResponseObject();
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SnapshotResponse;
|
import com.cloud.api.response.SnapshotResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.Snapshot.SnapshotType;
|
import com.cloud.storage.Snapshot.SnapshotType;
|
||||||
import com.cloud.storage.SnapshotVO;
|
import com.cloud.storage.SnapshotVO;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
@ -78,6 +79,27 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
|||||||
return "snapshot";
|
return "snapshot";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VolumeVO volume = ApiDBUtils.findVolumeById(getVolumeId());
|
||||||
|
if (volume != null) {
|
||||||
|
return volume.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_SNAPSHOT_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "creating snapshot for volume: " + getVolumeId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SnapshotResponse getResponse() {
|
public SnapshotResponse getResponse() {
|
||||||
SnapshotVO snapshot = (SnapshotVO)getResponseObject();
|
SnapshotVO snapshot = (SnapshotVO)getResponseObject();
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.TemplateResponse;
|
import com.cloud.api.response.TemplateResponse;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.GuestOS;
|
import com.cloud.storage.GuestOS;
|
||||||
import com.cloud.storage.Snapshot;
|
import com.cloud.storage.Snapshot;
|
||||||
import com.cloud.storage.VMTemplateHostVO;
|
import com.cloud.storage.VMTemplateHostVO;
|
||||||
@ -131,6 +132,36 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
|
|||||||
return "template";
|
return "template";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Long volumeId = getVolumeId();
|
||||||
|
Long snapshotId = getSnapshotId();
|
||||||
|
if (volumeId != null) {
|
||||||
|
VolumeVO volume = ApiDBUtils.findVolumeById(volumeId);
|
||||||
|
if (volume != null) {
|
||||||
|
return volume.getAccountId();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId);
|
||||||
|
if (snapshot != null) {
|
||||||
|
return snapshot.getAccountId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_TEMPLATE_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "creating template: " + getTemplateName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public TemplateResponse getResponse() {
|
public TemplateResponse getResponse() {
|
||||||
VMTemplateVO template = (VMTemplateVO)getResponseObject();
|
VMTemplateVO template = (VMTemplateVO)getResponseObject();
|
||||||
|
|||||||
@ -26,8 +26,11 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.VolumeResponse;
|
import com.cloud.api.response.VolumeResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.DiskOfferingVO;
|
import com.cloud.storage.DiskOfferingVO;
|
||||||
import com.cloud.storage.VolumeVO;
|
import com.cloud.storage.VolumeVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(createMethod="createVolumeDB", method="createVolume", manager=Manager.StorageManager)
|
@Implementation(createMethod="createVolumeDB", method="createVolume", manager=Manager.StorageManager)
|
||||||
public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||||
@ -106,6 +109,35 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
|||||||
return "volume";
|
return "volume";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if ((account == null) || isAdmin(account.getType())) {
|
||||||
|
if ((domainId != null) && (accountName != null)) {
|
||||||
|
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||||
|
if (userAccount != null) {
|
||||||
|
return userAccount.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VOLUME_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "creating volume: " + getVolumeName() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId());
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public VolumeResponse getResponse() {
|
public VolumeResponse getResponse() {
|
||||||
VolumeVO volume = (VolumeVO)getResponseObject();
|
VolumeVO volume = (VolumeVO)getResponseObject();
|
||||||
|
|||||||
@ -19,10 +19,14 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.DeleteDomainResponse;
|
import com.cloud.api.response.DeleteDomainResponse;
|
||||||
|
import com.cloud.domain.DomainVO;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="deleteDomain")
|
@Implementation(method="deleteDomain")
|
||||||
public class DeleteDomainCmd extends BaseAsyncCmd {
|
public class DeleteDomainCmd extends BaseAsyncCmd {
|
||||||
@ -52,7 +56,6 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
|
|||||||
return cleanup;
|
return cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -62,6 +65,26 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
DomainVO domain = ApiDBUtils.findDomainById(getId());
|
||||||
|
if (domain != null) {
|
||||||
|
return domain.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_DOMAIN_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting domain: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public DeleteDomainResponse getResponse() {
|
public DeleteDomainResponse getResponse() {
|
||||||
String deleteResult = (String)getResponseObject();
|
String deleteResult = (String)getResponseObject();
|
||||||
|
|||||||
@ -19,11 +19,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="deleteLoadBalancerRule", manager=Manager.NetworkManager)
|
@Implementation(method="deleteLoadBalancerRule", manager=Manager.NetworkManager)
|
||||||
public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
|
public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
|
||||||
@ -54,6 +58,26 @@ public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
LoadBalancerVO lb = ApiDBUtils.findLoadBalancerById(getId());
|
||||||
|
if (lb != null) {
|
||||||
|
return lb.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_LOAD_BALANCER_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting load balancer: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -20,6 +20,7 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
@ -27,6 +28,9 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="deleteSecurityGroup", manager=Manager.ManagementServer)
|
@Implementation(method="deleteSecurityGroup", manager=Manager.ManagementServer)
|
||||||
public class DeletePortForwardingServiceCmd extends BaseAsyncCmd {
|
public class DeletePortForwardingServiceCmd extends BaseAsyncCmd {
|
||||||
@ -53,10 +57,31 @@ public class DeletePortForwardingServiceCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
SecurityGroupVO sg = ApiDBUtils.findPortForwardingServiceById(getId());
|
||||||
|
if (sg != null) {
|
||||||
|
return sg.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_PORT_FORWARDING_SERVICE_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting port forwarding service: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -20,11 +20,16 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.NetworkRuleConfigVO;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="deleteNetworkRuleConfig", manager=Manager.NetworkManager)
|
@Implementation(method="deleteNetworkRuleConfig", manager=Manager.NetworkManager)
|
||||||
public class DeletePortForwardingServiceRuleCmd extends BaseAsyncCmd {
|
public class DeletePortForwardingServiceRuleCmd extends BaseAsyncCmd {
|
||||||
@ -56,6 +61,27 @@ public class DeletePortForwardingServiceRuleCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
NetworkRuleConfigVO netRule = ApiDBUtils.findNetworkRuleById(getId());
|
||||||
|
if (netRule != null) {
|
||||||
|
SecurityGroupVO sg = ApiDBUtils.findPortForwardingServiceById(netRule.getSecurityGroupId());
|
||||||
|
return sg.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NET_RULE_DELETE; // FIXME: add a new event type for this?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting port forwarding service rule: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -20,11 +20,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.Snapshot;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="deleteSnapshot", manager=Manager.SnapshotManager)
|
@Implementation(method="deleteSnapshot", manager=Manager.SnapshotManager)
|
||||||
public class DeleteSnapshotCmd extends BaseAsyncCmd {
|
public class DeleteSnapshotCmd extends BaseAsyncCmd {
|
||||||
@ -61,7 +65,6 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -71,6 +74,26 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Snapshot snapshot = ApiDBUtils.findSnapshotById(getId());
|
||||||
|
if (snapshot != null) {
|
||||||
|
return snapshot.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_SNAPSHOT_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting snapshot: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -25,6 +25,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="deleteUser", manager=Manager.ManagementServer)
|
@Implementation(method="deleteUser", manager=Manager.ManagementServer)
|
||||||
public class DeleteUserCmd extends BaseAsyncCmd {
|
public class DeleteUserCmd extends BaseAsyncCmd {
|
||||||
@ -61,6 +64,26 @@ public class DeleteUserCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_USER_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deleting user: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -27,8 +27,8 @@ import com.cloud.api.BaseAsyncCmd;
|
|||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ResponseObject;
|
|
||||||
import com.cloud.api.response.UserVmResponse;
|
import com.cloud.api.response.UserVmResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -154,6 +154,35 @@ public class DeployVMCmd extends BaseAsyncCmd {
|
|||||||
return "virtualmachine";
|
return "virtualmachine";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if ((account == null) || isAdmin(account.getType())) {
|
||||||
|
if ((domainId != null) && (accountName != null)) {
|
||||||
|
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||||
|
if (userAccount != null) {
|
||||||
|
return userAccount.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "deploying Vm";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public UserVmResponse getResponse() {
|
public UserVmResponse getResponse() {
|
||||||
UserVm userVm = (UserVm)getResponseObject();
|
UserVm userVm = (UserVm)getResponseObject();
|
||||||
|
|||||||
@ -24,8 +24,10 @@ import com.cloud.api.BaseAsyncCmd;
|
|||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ResponseObject;
|
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="destroyConsoleProxy", manager=Manager.ConsoleProxyManager)
|
@Implementation(method="destroyConsoleProxy", manager=Manager.ConsoleProxyManager)
|
||||||
public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
|
public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
|
||||||
@ -59,8 +61,28 @@ public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseObject getResponse() {
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_PROXY_DESTROY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "destroying console proxy: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
response.setSuccess(success);
|
response.setSuccess(success);
|
||||||
|
|||||||
@ -19,12 +19,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ResponseObject;
|
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="destroyVm", manager=Manager.UserVmManager)
|
@Implementation(method="destroyVm", manager=Manager.UserVmManager)
|
||||||
public class DestroyVMCmd extends BaseAsyncCmd {
|
public class DestroyVMCmd extends BaseAsyncCmd {
|
||||||
@ -51,10 +54,31 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_DESTROY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "destroying vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -21,9 +21,13 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="detachIso", manager=Manager.TemplateManager)
|
@Implementation(method="detachIso", manager=Manager.TemplateManager)
|
||||||
public class DetachIsoCmd extends BaseAsyncCmd {
|
public class DetachIsoCmd extends BaseAsyncCmd {
|
||||||
@ -55,6 +59,26 @@ public class DetachIsoCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getVirtualMachineId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ISO_DETACH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "detaching ISO from vm: " + getVirtualMachineId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -19,11 +19,16 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.VolumeVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="detachVolumeFromVM", manager=Manager.UserVmManager)
|
@Implementation(method="detachVolumeFromVM", manager=Manager.UserVmManager)
|
||||||
public class DetachVolumeCmd extends BaseAsyncCmd {
|
public class DetachVolumeCmd extends BaseAsyncCmd {
|
||||||
@ -72,6 +77,43 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
|
|||||||
return "volume";
|
return "volume";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Long volumeId = getId();
|
||||||
|
if (volumeId != null) {
|
||||||
|
VolumeVO volume = ApiDBUtils.findVolumeById(volumeId);
|
||||||
|
if (volume != null) {
|
||||||
|
return volume.getAccountId();
|
||||||
|
}
|
||||||
|
} else if (getVirtualMachineId() != null) {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getVirtualMachineId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid id, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VOLUME_DETACH;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (id != null) {
|
||||||
|
sb.append(": " + id);
|
||||||
|
} else if ((deviceId != null) && (virtualMachineId != null)) {
|
||||||
|
sb.append(" with device id: " + deviceId + " from vm: " + virtualMachineId);
|
||||||
|
} else {
|
||||||
|
sb.append(" <error: either volume id or deviceId/vmId need to be specified>");
|
||||||
|
}
|
||||||
|
return "detaching volume" + sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="disableAccount", manager=Manager.ManagementServer)
|
@Implementation(method="disableAccount", manager=Manager.ManagementServer)
|
||||||
public class DisableAccountCmd extends BaseAsyncCmd {
|
public class DisableAccountCmd extends BaseAsyncCmd {
|
||||||
@ -61,6 +64,26 @@ public class DisableAccountCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ACCOUNT_DISABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "disabling account: " + getAccountName() + " in domain: " + getDomainId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -23,6 +23,9 @@ import com.cloud.api.BaseAsyncCmd;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="disableUser")
|
@Implementation(method="disableUser")
|
||||||
public class DisableUserCmd extends BaseAsyncCmd {
|
public class DisableUserCmd extends BaseAsyncCmd {
|
||||||
@ -53,6 +56,26 @@ public class DisableUserCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_USER_DISABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "disabling user: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -19,11 +19,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.ExtractResponse;
|
import com.cloud.api.response.ExtractResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="extract", manager=Manager.TemplateManager)
|
@Implementation(method="extract", manager=Manager.TemplateManager)
|
||||||
public class ExtractIsoCmd extends BaseAsyncCmd {
|
public class ExtractIsoCmd extends BaseAsyncCmd {
|
||||||
@ -69,6 +73,27 @@ public class ExtractIsoCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ISO_EXTRACT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VMTemplateVO iso = ApiDBUtils.findTemplateById(getId());
|
||||||
|
if (iso != null) {
|
||||||
|
return iso.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid id, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Extraction job";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public ExtractResponse getResponse() {
|
public ExtractResponse getResponse() {
|
||||||
ExtractResponse response = (ExtractResponse)getResponseObject();
|
ExtractResponse response = (ExtractResponse)getResponseObject();
|
||||||
|
|||||||
@ -21,9 +21,13 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.ExtractResponse;
|
import com.cloud.api.response.ExtractResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.VMTemplateVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="extract", manager=Manager.TemplateManager)
|
@Implementation(method="extract", manager=Manager.TemplateManager)
|
||||||
public class ExtractTemplateCmd extends BaseAsyncCmd {
|
public class ExtractTemplateCmd extends BaseAsyncCmd {
|
||||||
@ -73,6 +77,27 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
|
|||||||
return "ExtractTemplate";
|
return "ExtractTemplate";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VMTemplateVO template = ApiDBUtils.findTemplateById(getId());
|
||||||
|
if (template != null) {
|
||||||
|
return template.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid id, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_TEMPLATE_EXTRACT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Extraction job";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public ExtractResponse getResponse() {
|
public ExtractResponse getResponse() {
|
||||||
ExtractResponse response = (ExtractResponse)getResponseObject();
|
ExtractResponse response = (ExtractResponse)getResponseObject();
|
||||||
|
|||||||
@ -19,10 +19,14 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.ExtractResponse;
|
import com.cloud.api.response.ExtractResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.storage.VolumeVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="extractVolume")
|
@Implementation(method="extractVolume")
|
||||||
public class ExtractVolumeCmd extends BaseAsyncCmd {
|
public class ExtractVolumeCmd extends BaseAsyncCmd {
|
||||||
@ -68,6 +72,27 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
VolumeVO volume = ApiDBUtils.findVolumeById(getId());
|
||||||
|
if (volume != null) {
|
||||||
|
return volume.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid id, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VOLUME_UPLOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Extraction job";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public ExtractResponse getResponse() {
|
public ExtractResponse getResponse() {
|
||||||
ExtractResponse response = (ExtractResponse)getResponseObject();
|
ExtractResponse response = (ExtractResponse)getResponseObject();
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="maintain", manager=Manager.AgentManager)
|
@Implementation(method="maintain", manager=Manager.AgentManager)
|
||||||
public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
|
public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
|
||||||
@ -59,6 +62,26 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
return "host";
|
return "host";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_MAINTENANCE_PREPARE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "preparing host: " + getId() + " for maintenance";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -24,6 +24,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="preparePrimaryStorageForMaintenance", manager=Manager.StorageManager)
|
@Implementation(method="preparePrimaryStorageForMaintenance", manager=Manager.StorageManager)
|
||||||
public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
|
public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
|
||||||
@ -58,6 +61,26 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
|
|||||||
return "primarystorage";
|
return "primarystorage";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_MAINTENANCE_PREPARE_PRIMARY_STORAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "preparing storage pool: " + getId() + " for maintenance";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -20,6 +20,7 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
@ -27,6 +28,9 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.vm.DomainRouterVO;
|
||||||
|
|
||||||
@Implementation(method="rebootRouter", manager=Manager.NetworkManager)
|
@Implementation(method="rebootRouter", manager=Manager.NetworkManager)
|
||||||
public class RebootRouterCmd extends BaseAsyncCmd {
|
public class RebootRouterCmd extends BaseAsyncCmd {
|
||||||
@ -52,10 +56,31 @@ public class RebootRouterCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
DomainRouterVO router = ApiDBUtils.findDomainRouterById(getId());
|
||||||
|
if (router != null) {
|
||||||
|
return router.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ROUTER_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "rebooting router: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -25,6 +25,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@Implementation(method="rebootSystemVM", manager=Manager.ManagementServer)
|
@Implementation(method="rebootSystemVM", manager=Manager.ManagementServer)
|
||||||
public class RebootSystemVmCmd extends BaseAsyncCmd {
|
public class RebootSystemVmCmd extends BaseAsyncCmd {
|
||||||
@ -56,7 +59,27 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_SSVM_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "rebooting system vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -19,11 +19,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="rebootVirtualMachine", manager=Manager.UserVmManager)
|
@Implementation(method="rebootVirtualMachine", manager=Manager.UserVmManager)
|
||||||
public class RebootVMCmd extends BaseAsyncCmd {
|
public class RebootVMCmd extends BaseAsyncCmd {
|
||||||
@ -54,6 +58,26 @@ public class RebootVMCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "rebooting user vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -33,12 +33,15 @@ import com.cloud.api.Implementation;
|
|||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.HostResponse;
|
import com.cloud.api.response.HostResponse;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.HostStats;
|
import com.cloud.host.HostStats;
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
import com.cloud.host.Status.Event;
|
import com.cloud.host.Status.Event;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.storage.GuestOSCategoryVO;
|
import com.cloud.storage.GuestOSCategoryVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.vm.UserVmVO;
|
import com.cloud.vm.UserVmVO;
|
||||||
|
|
||||||
@Implementation(method="reconnectHost", manager=Manager.AgentManager)
|
@Implementation(method="reconnectHost", manager=Manager.AgentManager)
|
||||||
@ -66,6 +69,7 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
|
|||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
@ -74,6 +78,26 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
|
|||||||
return "host";
|
return "host";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_HOST_RECONNECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "reconnecting host: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public HostResponse getResponse() {
|
public HostResponse getResponse() {
|
||||||
HostVO host = (HostVO)getResponseObject();
|
HostVO host = (HostVO)getResponseObject();
|
||||||
|
|||||||
@ -17,15 +17,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.StringUtils;
|
||||||
|
|
||||||
@Implementation(method="removeFromLoadBalancer", manager=Manager.NetworkManager)
|
@Implementation(method="removeFromLoadBalancer", manager=Manager.NetworkManager)
|
||||||
public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd {
|
public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd {
|
||||||
@ -71,6 +77,31 @@ public class RemoveFromLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
LoadBalancerVO lb = ApiDBUtils.findLoadBalancerById(getId());
|
||||||
|
if (lb == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return lb.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_REMOVE_FROM_LOAD_BALANCER_RULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
List<Long> vmIds = getVirtualMachineIds();
|
||||||
|
if ((vmIds == null) || vmIds.isEmpty()) {
|
||||||
|
vmIds = new ArrayList<Long>();
|
||||||
|
vmIds.add(getVirtualMachineId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return "removing instances from load balancer: " + getId() + " (ids: " + StringUtils.join(vmIds, ",") + ")";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -21,9 +21,13 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.network.SecurityGroupVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="removeSecurityGroup", manager=Manager.ManagementServer)
|
@Implementation(method="removeSecurityGroup", manager=Manager.ManagementServer)
|
||||||
public class RemovePortForwardingServiceCmd extends BaseAsyncCmd {
|
public class RemovePortForwardingServiceCmd extends BaseAsyncCmd {
|
||||||
@ -69,6 +73,26 @@ public class RemovePortForwardingServiceCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
SecurityGroupVO sg = ApiDBUtils.findPortForwardingServiceById(getId());
|
||||||
|
if (sg != null) {
|
||||||
|
return sg.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_PORT_FORWARDING_SERVICE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "removing port forwarding service: " + getId() + " from vm: " + getVirtualMachineId() + " on IP: " + getPublicIp();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -21,9 +21,13 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="resetVMPassword", manager=Manager.UserVmManager)
|
@Implementation(method="resetVMPassword", manager=Manager.UserVmManager)
|
||||||
public class ResetVMPasswordCmd extends BaseAsyncCmd {
|
public class ResetVMPasswordCmd extends BaseAsyncCmd {
|
||||||
@ -55,6 +59,26 @@ public class ResetVMPasswordCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_RESETPASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "resetting password for vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
|||||||
@ -1,14 +1,21 @@
|
|||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Implementation(method="revokeNetworkGroupIngress", manager=Manager.NetworkGroupManager)
|
@Implementation(method="revokeNetworkGroupIngress", manager=Manager.NetworkGroupManager)
|
||||||
@ -108,7 +115,59 @@ public class RevokeNetworkGroupIngressCmd extends BaseAsyncCmd {
|
|||||||
return "revokenetworkgroupingress";
|
return "revokenetworkgroupingress";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if ((account == null) || isAdmin(account.getType())) {
|
||||||
|
if ((domainId != null) && (accountName != null)) {
|
||||||
|
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
|
||||||
|
if (userAccount != null) {
|
||||||
|
return userAccount.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NETWORK_GROUP_REVOKE_INGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (getUserNetworkGroupList() != null) {
|
||||||
|
sb.append("group list(group/account): ");
|
||||||
|
Collection userGroupCollection = getUserNetworkGroupList().values();
|
||||||
|
Iterator iter = userGroupCollection.iterator();
|
||||||
|
|
||||||
|
HashMap userGroup = (HashMap)iter.next();
|
||||||
|
String group = (String)userGroup.get("group");
|
||||||
|
String authorizedAccountName = (String)userGroup.get("account");
|
||||||
|
sb.append(group + "/" + authorizedAccountName);
|
||||||
|
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
userGroup = (HashMap)iter.next();
|
||||||
|
group = (String)userGroup.get("group");
|
||||||
|
authorizedAccountName = (String)userGroup.get("account");
|
||||||
|
sb.append(", " + group + "/" + authorizedAccountName);
|
||||||
|
}
|
||||||
|
} else if (getCidrList() != null) {
|
||||||
|
sb.append("cidr list: " + getCidrList());
|
||||||
|
} else {
|
||||||
|
sb.append("<error: no ingress parameters>");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "revoking ingress from group: " + getNetworkGroupName() + " for " + sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
Boolean success = (Boolean)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
SuccessResponse response = new SuccessResponse();
|
SuccessResponse response = new SuccessResponse();
|
||||||
|
|||||||
@ -26,7 +26,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.DomainRouterResponse;
|
import com.cloud.api.response.DomainRouterResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
|
|
||||||
|
|
||||||
@ -63,6 +65,26 @@ public class StartRouterCmd extends BaseAsyncCmd {
|
|||||||
return "router";
|
return "router";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ROUTER_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "starting router: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public DomainRouterResponse getResponse() {
|
public DomainRouterResponse getResponse() {
|
||||||
DomainRouterResponse routerResponse = new DomainRouterResponse();
|
DomainRouterResponse routerResponse = new DomainRouterResponse();
|
||||||
|
|||||||
@ -26,6 +26,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SystemVmResponse;
|
import com.cloud.api.response.SystemVmResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.vm.ConsoleProxyVO;
|
import com.cloud.vm.ConsoleProxyVO;
|
||||||
import com.cloud.vm.SecondaryStorageVmVO;
|
import com.cloud.vm.SecondaryStorageVmVO;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
@ -64,6 +67,26 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
|
|||||||
return "systemvm";
|
return "systemvm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_SSVM_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "starting system vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SystemVmResponse getResponse() {
|
public SystemVmResponse getResponse() {
|
||||||
VMInstanceVO instance = (VMInstanceVO)getResponseObject();
|
VMInstanceVO instance = (VMInstanceVO)getResponseObject();
|
||||||
|
|||||||
@ -26,8 +26,8 @@ import com.cloud.api.BaseCmd;
|
|||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ResponseObject;
|
|
||||||
import com.cloud.api.response.UserVmResponse;
|
import com.cloud.api.response.UserVmResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
import com.cloud.storage.VMTemplateVO;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
@ -63,11 +63,31 @@ public class StartVMCmd extends BaseAsyncCmd {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getResultObjectName() {
|
public static String getResultObjectName() {
|
||||||
return "virtualmachine";
|
return "virtualmachine";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "starting user vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public UserVmResponse getResponse() {
|
public UserVmResponse getResponse() {
|
||||||
UserVm vm = (UserVm)getResponseObject();
|
UserVm vm = (UserVm)getResponseObject();
|
||||||
|
|||||||
@ -20,13 +20,16 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.response.DomainRouterResponse;
|
||||||
import com.cloud.api.response.SuccessResponse;
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.uservm.UserVm;
|
||||||
|
import com.cloud.vm.DomainRouterVO;
|
||||||
|
|
||||||
|
|
||||||
@Implementation(method="stopRouter", manager=Manager.NetworkManager)
|
@Implementation(method="stopRouter", manager=Manager.NetworkManager)
|
||||||
@ -56,16 +59,67 @@ public class StopRouterCmd extends BaseAsyncCmd {
|
|||||||
public String getName() {
|
public String getName() {
|
||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_ROUTER_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "stopping router: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SuccessResponse getResponse() {
|
public DomainRouterResponse getResponse() {
|
||||||
SuccessResponse response = new SuccessResponse();
|
DomainRouterVO router = (DomainRouterVO)getResponseObject();
|
||||||
Boolean responseObject = (Boolean)getResponseObject();
|
|
||||||
|
DomainRouterResponse response = new DomainRouterResponse();
|
||||||
if (responseObject != null) {
|
response.setId(router.getId());
|
||||||
response.setSuccess(responseObject);
|
response.setZoneId(router.getDataCenterId());
|
||||||
} else {
|
response.setZoneName(ApiDBUtils.findZoneById(router.getDataCenterId()).getName());
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
|
response.setDns1(router.getDns1());
|
||||||
|
response.setDns2(router.getDns2());
|
||||||
|
response.setNetworkDomain(router.getDomain());
|
||||||
|
response.setGateway(router.getGateway());
|
||||||
|
response.setName(router.getName());
|
||||||
|
response.setPodId(router.getPodId());
|
||||||
|
response.setPrivateIp(router.getPrivateIpAddress());
|
||||||
|
response.setPrivateMacAddress(router.getPrivateMacAddress());
|
||||||
|
response.setPrivateNetmask(router.getPrivateNetmask());
|
||||||
|
response.setPublicIp(router.getPublicIpAddress());
|
||||||
|
response.setPublicMacAddress(router.getPublicMacAddress());
|
||||||
|
response.setPublicNetmask(router.getPrivateNetmask());
|
||||||
|
response.setGuestIpAddress(router.getGuestIpAddress());
|
||||||
|
response.setGuestMacAddress(router.getGuestMacAddress());
|
||||||
|
response.setTemplateId(router.getTemplateId());
|
||||||
|
response.setCreated(router.getCreated());
|
||||||
|
response.setGuestNetmask(router.getGuestNetmask());
|
||||||
|
|
||||||
|
if (router.getHostId() != null) {
|
||||||
|
response.setHostName(ApiDBUtils.findHostById(router.getHostId()).getName());
|
||||||
|
response.setHostId(router.getHostId());
|
||||||
|
}
|
||||||
|
|
||||||
|
Account acct = ApiDBUtils.findAccountById(router.getAccountId());
|
||||||
|
if (acct != null) {
|
||||||
|
response.setAccountName(acct.getAccountName());
|
||||||
|
response.setDomainId(acct.getDomainId());
|
||||||
|
response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (router.getState() != null) {
|
||||||
|
response.setState(router.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
response.setResponseName(getName());
|
response.setResponseName(getName());
|
||||||
|
|||||||
@ -26,6 +26,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.SystemVmResponse;
|
import com.cloud.api.response.SystemVmResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.user.UserContext;
|
||||||
import com.cloud.vm.ConsoleProxyVO;
|
import com.cloud.vm.ConsoleProxyVO;
|
||||||
import com.cloud.vm.SecondaryStorageVmVO;
|
import com.cloud.vm.SecondaryStorageVmVO;
|
||||||
import com.cloud.vm.VMInstanceVO;
|
import com.cloud.vm.VMInstanceVO;
|
||||||
@ -60,6 +63,26 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
if (account != null) {
|
||||||
|
return account.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_SSVM_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "stopping system vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public SystemVmResponse getResponse() {
|
public SystemVmResponse getResponse() {
|
||||||
VMInstanceVO instance = (VMInstanceVO)getResponseObject();
|
VMInstanceVO instance = (VMInstanceVO)getResponseObject();
|
||||||
|
|||||||
@ -19,18 +19,15 @@ package com.cloud.api.commands;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiDBUtils;
|
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
import com.cloud.api.BaseCmd;
|
|
||||||
import com.cloud.api.BaseCmd.Manager;
|
import com.cloud.api.BaseCmd.Manager;
|
||||||
|
import com.cloud.api.ApiDBUtils;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.UserVmResponse;
|
import com.cloud.api.response.SuccessResponse;
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.storage.VMTemplateVO;
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
import com.cloud.vm.InstanceGroupVO;
|
|
||||||
|
|
||||||
@Implementation(method="stopVirtualMachine", manager=Manager.UserVmManager)
|
@Implementation(method="stopVirtualMachine", manager=Manager.UserVmManager)
|
||||||
public class StopVMCmd extends BaseAsyncCmd {
|
public class StopVMCmd extends BaseAsyncCmd {
|
||||||
@ -62,94 +59,31 @@ public class StopVMCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||||
|
if (vm != null) {
|
||||||
|
return vm.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_VM_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "stopping user vm: " + getId();
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public UserVmResponse getResponse() {
|
public SuccessResponse getResponse() {
|
||||||
UserVm vm = (UserVm)getResponseObject();
|
Boolean success = (Boolean)getResponseObject();
|
||||||
|
SuccessResponse response = new SuccessResponse();
|
||||||
UserVmResponse response = new UserVmResponse();
|
response.setSuccess(success);
|
||||||
response.setId(vm.getId());
|
|
||||||
response.setName(vm.getName());
|
|
||||||
response.setCreated(vm.getCreated());
|
|
||||||
response.setZoneId(vm.getDataCenterId());
|
|
||||||
response.setZoneName(ApiDBUtils.findZoneById(vm.getDataCenterId()).getName());
|
|
||||||
response.setIpAddress(vm.getPrivateIpAddress());
|
|
||||||
response.setServiceOfferingId(vm.getServiceOfferingId());
|
|
||||||
response.setHaEnable(vm.isHaEnabled());
|
|
||||||
if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
|
|
||||||
response.setDisplayName(vm.getName());
|
|
||||||
} else {
|
|
||||||
response.setDisplayName(vm.getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceGroupVO group = ApiDBUtils.findInstanceGroupForVM(vm.getId());
|
|
||||||
if (group != null) {
|
|
||||||
response.setGroup(group.getName());
|
|
||||||
response.setGroupId(group.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vm.getState() != null) {
|
|
||||||
response.setState(vm.getState().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
Account acct = ApiDBUtils.findAccountById(vm.getAccountId());
|
|
||||||
if (acct != null) {
|
|
||||||
response.setAccountName(acct.getAccountName());
|
|
||||||
response.setDomainId(acct.getDomainId());
|
|
||||||
response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null)) {
|
|
||||||
response.setHostName(ApiDBUtils.findHostById(vm.getHostId()).getName());
|
|
||||||
response.setHostId(vm.getHostId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String templateName = "ISO Boot";
|
|
||||||
boolean templatePasswordEnabled = false;
|
|
||||||
String templateDisplayText = "ISO Boot";
|
|
||||||
|
|
||||||
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
|
|
||||||
if (template != null) {
|
|
||||||
templateName = template.getName();
|
|
||||||
templatePasswordEnabled = template.getEnablePassword();
|
|
||||||
templateDisplayText = template.getDisplayText();
|
|
||||||
if (templateDisplayText == null) {
|
|
||||||
templateDisplayText = templateName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setTemplateId(vm.getTemplateId());
|
|
||||||
response.setTemplateName(templateName);
|
|
||||||
response.setTemplateDisplayText(templateDisplayText);
|
|
||||||
response.setPasswordEnabled(templatePasswordEnabled);
|
|
||||||
if (templatePasswordEnabled) {
|
|
||||||
response.setPassword(null); // FIXME: Where should password come from? In the old framework, password was always passed
|
|
||||||
// in to composeResultObject() as null, so that behavior is preserved...
|
|
||||||
} else {
|
|
||||||
response.setPassword("");
|
|
||||||
}
|
|
||||||
|
|
||||||
String isoName = null;
|
|
||||||
if (vm.getIsoId() != null) {
|
|
||||||
VMTemplateVO iso = ApiDBUtils.findTemplateById(vm.getIsoId().longValue());
|
|
||||||
if (iso != null) {
|
|
||||||
isoName = iso.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setIsoId(vm.getIsoId());
|
|
||||||
response.setIsoName(isoName);
|
|
||||||
|
|
||||||
ServiceOffering offering = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
|
|
||||||
response.setServiceOfferingId(vm.getServiceOfferingId());
|
|
||||||
response.setServiceOfferingName(offering.getName());
|
|
||||||
|
|
||||||
response.setCpuNumber(offering.getCpu());
|
|
||||||
response.setCpuSpeed(offering.getSpeed());
|
|
||||||
response.setMemory(offering.getRamSize());
|
|
||||||
|
|
||||||
//Network groups
|
|
||||||
response.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(vm.getId()));
|
|
||||||
|
|
||||||
response.setResponseName(getName());
|
response.setResponseName(getName());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,10 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.FirewallRuleResponse;
|
import com.cloud.api.response.FirewallRuleResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.network.FirewallRuleVO;
|
import com.cloud.network.FirewallRuleVO;
|
||||||
|
import com.cloud.network.IPAddressVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
import com.cloud.uservm.UserVm;
|
import com.cloud.uservm.UserVm;
|
||||||
|
|
||||||
@Implementation(method="updatePortForwardingRule", manager=Manager.ManagementServer)
|
@Implementation(method="updatePortForwardingRule", manager=Manager.ManagementServer)
|
||||||
@ -75,6 +78,27 @@ public class UpdateIPForwardingRuleCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
IPAddressVO addr = ApiDBUtils.findIpAddressById(getPublicIp());
|
||||||
|
if (addr != null) {
|
||||||
|
return addr.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// bad address given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_NET_RULE_MODIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "updating port forwarding rule";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public FirewallRuleResponse getResponse() {
|
public FirewallRuleResponse getResponse() {
|
||||||
FirewallRuleVO fwRule = (FirewallRuleVO)getResponseObject();
|
FirewallRuleVO fwRule = (FirewallRuleVO)getResponseObject();
|
||||||
|
|||||||
@ -25,7 +25,9 @@ import com.cloud.api.BaseCmd.Manager;
|
|||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.response.LoadBalancerResponse;
|
import com.cloud.api.response.LoadBalancerResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
import com.cloud.network.LoadBalancerVO;
|
import com.cloud.network.LoadBalancerVO;
|
||||||
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(method="updateLoadBalancerRule", manager=Manager.NetworkManager)
|
@Implementation(method="updateLoadBalancerRule", manager=Manager.NetworkManager)
|
||||||
public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
|
public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
|
||||||
@ -84,6 +86,25 @@ public class UpdateLoadBalancerRuleCmd extends BaseAsyncCmd {
|
|||||||
return s_name;
|
return s_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getAccountId() {
|
||||||
|
LoadBalancerVO lb = ApiDBUtils.findLoadBalancerById(getId());
|
||||||
|
if (lb == null) {
|
||||||
|
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||||
|
}
|
||||||
|
return lb.getAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_LOAD_BALANCER_UPDATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "updating load balancer rule";
|
||||||
|
}
|
||||||
|
|
||||||
@Override @SuppressWarnings("unchecked")
|
@Override @SuppressWarnings("unchecked")
|
||||||
public LoadBalancerResponse getResponse() {
|
public LoadBalancerResponse getResponse() {
|
||||||
LoadBalancerVO loadBalancer = (LoadBalancerVO)getResponseObject();
|
LoadBalancerVO loadBalancer = (LoadBalancerVO)getResponseObject();
|
||||||
|
|||||||
@ -140,10 +140,10 @@ public interface NetworkManager extends Manager {
|
|||||||
/**
|
/**
|
||||||
* Stops domain router
|
* Stops domain router
|
||||||
* @param cmd the command specifying router's id
|
* @param cmd the command specifying router's id
|
||||||
* @return success or failure
|
* @return router if successful, null otherwise
|
||||||
* @throws InvalidParameterValueException, PermissionDeniedException
|
* @throws InvalidParameterValueException, PermissionDeniedException
|
||||||
*/
|
*/
|
||||||
boolean stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
DomainRouterVO stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
|
||||||
|
|
||||||
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
||||||
|
|
||||||
|
|||||||
@ -1280,7 +1280,7 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
public DomainRouterVO stopRouter(StopRouterCmd cmd) throws InvalidParameterValueException, PermissionDeniedException{
|
||||||
Long routerId = cmd.getId();
|
Long routerId = cmd.getId();
|
||||||
Account account = (Account)UserContext.current().getAccountObject();
|
Account account = (Account)UserContext.current().getAccountObject();
|
||||||
|
|
||||||
@ -1296,7 +1296,12 @@ public class NetworkManagerImpl implements NetworkManager, VirtualMachineManager
|
|||||||
|
|
||||||
long eventId = EventUtils.saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_ROUTER_STOP, "stopping Router with Id: "+routerId);
|
long eventId = EventUtils.saveScheduledEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, EventTypes.EVENT_ROUTER_STOP, "stopping Router with Id: "+routerId);
|
||||||
|
|
||||||
return stopRouter(routerId, eventId);
|
boolean success = stopRouter(routerId, eventId);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
return _routerDao.findById(routerId);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
|
|||||||
@ -83,6 +83,7 @@ import com.cloud.dc.HostPodVO;
|
|||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
import com.cloud.dc.dao.HostPodDao;
|
import com.cloud.dc.dao.HostPodDao;
|
||||||
import com.cloud.deploy.DeployDestination;
|
import com.cloud.deploy.DeployDestination;
|
||||||
|
import com.cloud.domain.Domain;
|
||||||
import com.cloud.domain.dao.DomainDao;
|
import com.cloud.domain.dao.DomainDao;
|
||||||
import com.cloud.event.EventState;
|
import com.cloud.event.EventState;
|
||||||
import com.cloud.event.EventTypes;
|
import com.cloud.event.EventTypes;
|
||||||
@ -292,7 +293,6 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
Host host = dest.getHost();
|
Host host = dest.getHost();
|
||||||
|
|
||||||
VolumeTO[] disks = new VolumeTO[vols.size()];
|
VolumeTO[] disks = new VolumeTO[vols.size()];
|
||||||
int i = 0;
|
|
||||||
Iterator<VolumeVO> it = vols.iterator();
|
Iterator<VolumeVO> it = vols.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
VolumeVO vol = it.next();
|
VolumeVO vol = it.next();
|
||||||
@ -653,14 +653,13 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
return new Pair<VolumeVO, String>(createdVolume, details);
|
return new Pair<VolumeVO, String>(createdVolume, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
private VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId/*, long startEventId*/) {
|
private VolumeVO createVolumeFromSnapshot(VolumeVO volume, long snapshotId, long startEventId) {
|
||||||
// FIXME: start event id needs to come from somewhere
|
|
||||||
EventVO event = new EventVO();
|
EventVO event = new EventVO();
|
||||||
event.setUserId(UserContext.current().getUserId());
|
event.setUserId(UserContext.current().getUserId());
|
||||||
event.setAccountId(volume.getAccountId());
|
event.setAccountId(volume.getAccountId());
|
||||||
event.setType(EventTypes.EVENT_VOLUME_CREATE);
|
event.setType(EventTypes.EVENT_VOLUME_CREATE);
|
||||||
event.setState(EventState.Started);
|
event.setState(EventState.Started);
|
||||||
// FIXME: event.setStartId(startEventId);
|
event.setStartId(startEventId);
|
||||||
event.setDescription("Creating volume from snapshot with id: "+snapshotId);
|
event.setDescription("Creating volume from snapshot with id: "+snapshotId);
|
||||||
_eventDao.persist(event);
|
_eventDao.persist(event);
|
||||||
|
|
||||||
@ -753,7 +752,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
event.setUserId(UserContext.current().getUserId());
|
event.setUserId(UserContext.current().getUserId());
|
||||||
event.setType(EventTypes.EVENT_VOLUME_CREATE);
|
event.setType(EventTypes.EVENT_VOLUME_CREATE);
|
||||||
event.setParameters(eventParams);
|
event.setParameters(eventParams);
|
||||||
// FIXME: event.setStartId(startEventId);
|
event.setStartId(startEventId);
|
||||||
event.setState(EventState.Completed);
|
event.setState(EventState.Completed);
|
||||||
if (createdVolume.getPath() != null) {
|
if (createdVolume.getPath() != null) {
|
||||||
event.setDescription("Created volume: "+ createdVolume.getName() + " with size: " + sizeMB + " MB in pool: " + poolName + " from snapshot id: " + snapshotId);
|
event.setDescription("Created volume: "+ createdVolume.getName() + " with size: " + sizeMB + " MB in pool: " + poolName + " from snapshot id: " + snapshotId);
|
||||||
@ -1846,14 +1845,14 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
volume.setDataCenterId(zoneId);
|
volume.setDataCenterId(zoneId);
|
||||||
volume.setPodId(null);
|
volume.setPodId(null);
|
||||||
volume.setAccountId(targetAccount.getId());
|
volume.setAccountId(targetAccount.getId());
|
||||||
volume.setDomainId(account.getDomainId());
|
volume.setDomainId(((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId()));
|
||||||
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
volume.setMirrorState(MirrorState.NOT_MIRRORED);
|
||||||
volume.setDiskOfferingId(cmd.getDiskOfferingId());
|
volume.setDiskOfferingId(cmd.getDiskOfferingId());
|
||||||
volume.setStorageResourceType(StorageResourceType.STORAGE_POOL);
|
volume.setStorageResourceType(StorageResourceType.STORAGE_POOL);
|
||||||
volume.setInstanceId(null);
|
volume.setInstanceId(null);
|
||||||
volume.setUpdated(new Date());
|
volume.setUpdated(new Date());
|
||||||
volume.setStatus(AsyncInstanceCreateStatus.Creating);
|
volume.setStatus(AsyncInstanceCreateStatus.Creating);
|
||||||
volume.setDomainId(account.getDomainId());
|
volume.setDomainId((account == null) ? Domain.ROOT_DOMAIN : account.getDomainId());
|
||||||
volume = _volsDao.persist(volume);
|
volume = _volsDao.persist(volume);
|
||||||
|
|
||||||
return volume;
|
return volume;
|
||||||
@ -1866,7 +1865,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||||||
Long userId = UserContext.current().getUserId();
|
Long userId = UserContext.current().getUserId();
|
||||||
|
|
||||||
if (cmd.getSnapshotId() != null) {
|
if (cmd.getSnapshotId() != null) {
|
||||||
return createVolumeFromSnapshot(volume, cmd.getSnapshotId());
|
return createVolumeFromSnapshot(volume, cmd.getSnapshotId(), cmd.getStartEventId());
|
||||||
} else {
|
} else {
|
||||||
DataCenterVO dc = _dcDao.findById(cmd.getZoneId());
|
DataCenterVO dc = _dcDao.findById(cmd.getZoneId());
|
||||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(cmd.getDiskOfferingId());
|
DiskOfferingVO diskOffering = _diskOfferingDao.findById(cmd.getDiskOfferingId());
|
||||||
|
|||||||
@ -48,10 +48,7 @@ import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
|
|||||||
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
|
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
|
||||||
import com.cloud.api.commands.ListSnapshotPoliciesCmd;
|
import com.cloud.api.commands.ListSnapshotPoliciesCmd;
|
||||||
import com.cloud.async.AsyncInstanceCreateStatus;
|
import com.cloud.async.AsyncInstanceCreateStatus;
|
||||||
import com.cloud.async.AsyncJobExecutor;
|
|
||||||
import com.cloud.async.AsyncJobManager;
|
import com.cloud.async.AsyncJobManager;
|
||||||
import com.cloud.async.AsyncJobVO;
|
|
||||||
import com.cloud.async.BaseAsyncJobExecutor;
|
|
||||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||||
import com.cloud.configuration.dao.ConfigurationDao;
|
import com.cloud.configuration.dao.ConfigurationDao;
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
import com.cloud.dc.dao.DataCenterDao;
|
||||||
@ -301,25 +298,19 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||||||
public SnapshotVO createSnapshotImpl(long volumeId, List<Long> policyIds) throws InvalidParameterValueException, ResourceAllocationException {
|
public SnapshotVO createSnapshotImpl(long volumeId, List<Long> policyIds) throws InvalidParameterValueException, ResourceAllocationException {
|
||||||
Long userId = UserContext.current().getUserId();
|
Long userId = UserContext.current().getUserId();
|
||||||
// Get the async job id from the context.
|
// Get the async job id from the context.
|
||||||
Long jobId = null;
|
// Long jobId = null;
|
||||||
AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
|
||||||
if(asyncExecutor != null) {
|
|
||||||
// createSnapshot is always async. Hence asyncExecutor is always not null.
|
|
||||||
AsyncJobVO job = asyncExecutor.getJob();
|
|
||||||
jobId = job.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
txn.start();
|
// txn.start();
|
||||||
// set the async_job_id for this in the schedule queue so that it doesn't get scheduled again and block others.
|
// // set the async_job_id for this in the schedule queue so that it doesn't get scheduled again and block others.
|
||||||
// mark each of the coinciding schedules as executing in the job queue.
|
// // mark each of the coinciding schedules as executing in the job queue.
|
||||||
for (Long policyId : policyIds) {
|
// for (Long policyId : policyIds) {
|
||||||
SnapshotScheduleVO snapshotSchedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false);
|
// SnapshotScheduleVO snapshotSchedule = _snapshotScheduleDao.getCurrentSchedule(volumeId, policyId, false);
|
||||||
assert snapshotSchedule != null;
|
// assert snapshotSchedule != null;
|
||||||
snapshotSchedule.setAsyncJobId(jobId);
|
// snapshotSchedule.setAsyncJobId(jobId);
|
||||||
_snapshotScheduleDao.update(snapshotSchedule.getId(), snapshotSchedule);
|
// _snapshotScheduleDao.update(snapshotSchedule.getId(), snapshotSchedule);
|
||||||
}
|
// }
|
||||||
txn.commit();
|
// txn.commit();
|
||||||
|
|
||||||
VolumeVO volume = _volsDao.lock(volumeId, true);
|
VolumeVO volume = _volsDao.lock(volumeId, true);
|
||||||
|
|
||||||
@ -405,16 +396,6 @@ public class SnapshotManagerImpl implements SnapshotManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update async status after snapshot creation and before backup
|
|
||||||
if(asyncExecutor != null) {
|
|
||||||
AsyncJobVO job = asyncExecutor.getJob();
|
|
||||||
|
|
||||||
if(s_logger.isDebugEnabled())
|
|
||||||
s_logger.debug("CreateSnapshot created a new instance " + id + ", update async job-" + job.getId() + " progress status");
|
|
||||||
|
|
||||||
_asyncMgr.updateAsyncJobAttachment(job.getId(), "snapshot", id);
|
|
||||||
_asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, id);
|
|
||||||
}
|
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
|
||||||
return createdSnapshot;
|
return createdSnapshot;
|
||||||
|
|||||||
@ -1950,7 +1950,7 @@ function showInstancesTab(p_domainId, p_account) {
|
|||||||
$("body").stopTime(timerKey);
|
$("body").stopTime(timerKey);
|
||||||
if (result.jobstatus == 1) {
|
if (result.jobstatus == 1) {
|
||||||
// Succeeded
|
// Succeeded
|
||||||
routerJSONToTemplate(result.router[0], template);
|
routerJSONToTemplate(result.jobresult.stoprouterresponse, template);
|
||||||
template.find(".loadingmessage_container .loadingmessage_top p").html("Your router has been successfully stopped.");
|
template.find(".loadingmessage_container .loadingmessage_top p").html("Your router has been successfully stopped.");
|
||||||
template.find(".loadingmessage_container").fadeIn("slow");
|
template.find(".loadingmessage_container").fadeIn("slow");
|
||||||
} else if (result.jobstatus == 2) {
|
} else if (result.jobstatus == 2) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user