From f9faf1aea2f3dbb47c60eaefcd999290dff837e7 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Wed, 31 Jul 2013 15:18:22 -0700 Subject: [PATCH] CLOUDSTACK-3982: listAccounts - count only UserVms when calculate total number of Running vms per account --- setup/db/db/schema-410to420.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 1650e2fb174..3f25c3b7e59 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -2211,3 +2211,14 @@ CREATE TABLE `cloud_usage`.`usage_vmsnapshot` ( ALTER TABLE volumes ADD COLUMN vm_snapshot_chain_size bigint(20) unsigned; INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'kvm.ssh.to.agent', 'true', 'Specify whether or not the management server is allowed to SSH into KVM Agents'); + +#update the account_vmstats_view - count only user vms +DROP VIEW IF EXISTS `cloud`.`account_vmstats_view`; +CREATE VIEW `cloud`.`account_vmstats_view` AS + SELECT + account_id, state, count(*) as vmcount + from + `cloud`.`vm_instance` + where + vm_type = 'User' + group by account_id , state; \ No newline at end of file