You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2013/01/25 04:31:52 UTC

[11/50] [abbrv] git commit: Summary: Fix schema-40to410.sql

Summary: Fix schema-40to410.sql 

Applied some formatting

Changed invalid comment

Added workaround for non existing table vm_template_iso

Fix non prefixed table names in views

Removed 'use cloud' statement

Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/3bac7b8c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/3bac7b8c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/3bac7b8c

Branch: refs/heads/javelin
Commit: 3bac7b8c07b21eaa3a7b244f4d74efa7b4b5b41f
Parents: fe994a6
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Jan 22 11:00:50 2013 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Jan 22 11:01:22 2013 +0100

----------------------------------------------------------------------
 setup/db/db/schema-40to410.sql | 1867 ++++++++++++++++++++---------------
 1 files changed, 1052 insertions(+), 815 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/3bac7b8c/setup/db/db/schema-40to410.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql
index 79b7f8f..947059e 100644
--- a/setup/db/db/schema-40to410.sql
+++ b/setup/db/db/schema-40to410.sql
@@ -141,863 +141,1100 @@ UPDATE `cloud`.`conditions` set uuid=id WHERE uuid is NULL;
 
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', '"detail.batch.query.size"', '2000', 'Default entity detail batch query size for listing');
 
---- DB views for list api ---
-use cloud;
+-- DB views for list api
 
 DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
 CREATE VIEW `cloud`.`user_vm_view` AS
-select
-vm_instance.id id,
-vm_instance.name name,
-user_vm.display_name display_name,
-user_vm.user_data user_data,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-instance_group.id instance_group_id,
-instance_group.uuid instance_group_uuid,
-instance_group.name instance_group_name,
-vm_instance.uuid uuid,
-vm_instance.last_host_id last_host_id,
-vm_instance.vm_type type,
-vm_instance.vnc_password vnc_password,
-vm_instance.limit_cpu_use limit_cpu_use,
-vm_instance.created created,
-vm_instance.state state,
-vm_instance.removed removed,
-vm_instance.ha_enabled ha_enabled,
-vm_instance.hypervisor_type hypervisor_type,
-vm_instance.instance_name instance_name,
-vm_instance.guest_os_id guest_os_id,
-guest_os.uuid guest_os_uuid,
-vm_instance.pod_id pod_id,
-host_pod_ref.uuid pod_uuid,
-vm_instance.private_ip_address private_ip_address,
-vm_instance.private_mac_address private_mac_address,
-vm_instance.vm_type vm_type,
-data_center.id data_center_id,
-data_center.uuid data_center_uuid,
-data_center.name data_center_name,
-data_center.is_security_group_enabled security_group_enabled,
-host.id host_id,
-host.uuid host_uuid,
-host.name host_name,
-vm_template.id template_id,
-vm_template.uuid template_uuid,
-vm_template.name template_name,
-vm_template.display_text template_display_text,
-vm_template.enable_password password_enabled,
-iso.id iso_id,
-iso.uuid iso_uuid,
-iso.name iso_name,
-iso.display_text iso_display_text,
-service_offering.id service_offering_id,
-disk_offering.uuid service_offering_uuid,
-service_offering.cpu cpu,
-service_offering.speed speed,
-service_offering.ram_size ram_size,
-disk_offering.name service_offering_name,
-storage_pool.id pool_id,
-storage_pool.uuid pool_uuid,
-storage_pool.pool_type pool_type,
-volumes.id volume_id,
-volumes.uuid volume_uuid,
-volumes.device_id volume_device_id,
-volumes.volume_type volume_type,
-security_group.id security_group_id,
-security_group.uuid security_group_uuid,
-security_group.name security_group_name,
-security_group.description security_group_description,
-nics.id nic_id,
-nics.uuid nic_uuid,
-nics.network_id network_id,
-nics.ip4_address ip_address,
-nics.default_nic is_default_nic,
-nics.gateway gateway,
-nics.netmask netmask,
-nics.mac_address mac_address,
-nics.broadcast_uri broadcast_uri,
-nics.isolation_uri isolation_uri,
-vpc.id vpc_id,
-vpc.uuid vpc_uuid,
-networks.uuid network_uuid,
-networks.traffic_type traffic_type,
-networks.guest_type guest_type,
-user_ip_address.id public_ip_id,
-user_ip_address.uuid public_ip_uuid,
-user_ip_address.public_ip_address public_ip_address,
-ssh_keypairs.keypair_name keypair_name,
-resource_tags.id tag_id,
-resource_tags.uuid tag_uuid,
-resource_tags.key tag_key,
-resource_tags.value tag_value,
-resource_tags.domain_id tag_domain_id,
-resource_tags.account_id tag_account_id,
-resource_tags.resource_id tag_resource_id,
-resource_tags.resource_uuid tag_resource_uuid,
-resource_tags.resource_type tag_resource_type,
-resource_tags.customer tag_customer,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from user_vm
-inner join vm_instance on vm_instance.id = user_vm.id and vm_instance.removed is NULL
-inner join account on vm_instance.account_id=account.id
-inner join domain on vm_instance.domain_id=domain.id
-left join guest_os on vm_instance.guest_os_id = guest_os.id
-left join host_pod_ref on vm_instance.pod_id = host_pod_ref.id
-left join projects on projects.project_account_id = account.id
-left join instance_group_vm_map on vm_instance.id=instance_group_vm_map.instance_id
-left join instance_group on instance_group_vm_map.group_id=instance_group.id
-left join data_center on vm_instance.data_center_id=data_center.id
-left join host on vm_instance.host_id=host.id
-left join vm_template on vm_instance.vm_template_id=vm_template.id
-left join vm_template iso on iso.id=user_vm.iso_id
-left join service_offering on vm_instance.service_offering_id=service_offering.id
-left join disk_offering  on vm_instance.service_offering_id=disk_offering.id
-left join volumes on vm_instance.id=volumes.instance_id
-left join storage_pool on volumes.pool_id=storage_pool.id
-left join security_group_vm_map on vm_instance.id=security_group_vm_map.instance_id
-left join security_group on security_group_vm_map.security_group_id=security_group.id
-left join nics on vm_instance.id=nics.instance_id
-left join networks on nics.network_id=networks.id
-left join vpc on networks.vpc_id = vpc.id
-left join user_ip_address on user_ip_address.vm_id=vm_instance.id
-left join user_vm_details on user_vm_details.vm_id=vm_instance.id and user_vm_details.name = "SSH.PublicKey"
-left join ssh_keypairs on ssh_keypairs.public_key = user_vm_details.value
-left join resource_tags on resource_tags.resource_id = vm_instance.id and resource_tags.resource_type = "UserVm"
-left join async_job on async_job.instance_id = vm_instance.id and async_job.instance_type = "VirtualMachine" and async_job.job_status = 0;
+    select 
+        vm_instance.id id,
+        vm_instance.name name,
+        user_vm.display_name display_name,
+        user_vm.user_data user_data,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        instance_group.id instance_group_id,
+        instance_group.uuid instance_group_uuid,
+        instance_group.name instance_group_name,
+        vm_instance.uuid uuid,
+        vm_instance.last_host_id last_host_id,
+        vm_instance.vm_type type,
+        vm_instance.vnc_password vnc_password,
+        vm_instance.limit_cpu_use limit_cpu_use,
+        vm_instance.created created,
+        vm_instance.state state,
+        vm_instance.removed removed,
+        vm_instance.ha_enabled ha_enabled,
+        vm_instance.hypervisor_type hypervisor_type,
+        vm_instance.instance_name instance_name,
+        vm_instance.guest_os_id guest_os_id,
+        guest_os.uuid guest_os_uuid,
+        vm_instance.pod_id pod_id,
+        host_pod_ref.uuid pod_uuid,
+        vm_instance.private_ip_address private_ip_address,
+        vm_instance.private_mac_address private_mac_address,
+        vm_instance.vm_type vm_type,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        data_center.is_security_group_enabled security_group_enabled,
+        host.id host_id,
+        host.uuid host_uuid,
+        host.name host_name,
+        vm_template.id template_id,
+        vm_template.uuid template_uuid,
+        vm_template.name template_name,
+        vm_template.display_text template_display_text,
+        vm_template.enable_password password_enabled,
+--        iso.id iso_id,
+--        iso.uuid iso_uuid,
+--        iso.name iso_name,
+--        iso.display_text iso_display_text,
+-- FIXME workaround
+        NULL iso_id,
+		NULL iso_uuid,
+        NULL iso_name,
+		NULL iso_display_text,        service_offering.id service_offering_id,
+-- end of workaround
+        disk_offering.uuid service_offering_uuid,
+        service_offering.cpu cpu,
+        service_offering.speed speed,
+        service_offering.ram_size ram_size,
+        disk_offering.name service_offering_name,
+        storage_pool.id pool_id,
+        storage_pool.uuid pool_uuid,
+        storage_pool.pool_type pool_type,
+        volumes.id volume_id,
+        volumes.uuid volume_uuid,
+        volumes.device_id volume_device_id,
+        volumes.volume_type volume_type,
+        security_group.id security_group_id,
+        security_group.uuid security_group_uuid,
+        security_group.name security_group_name,
+        security_group.description security_group_description,
+        nics.id nic_id,
+        nics.uuid nic_uuid,
+        nics.network_id network_id,
+        nics.ip4_address ip_address,
+        nics.default_nic is_default_nic,
+        nics.gateway gateway,
+        nics.netmask netmask,
+        nics.mac_address mac_address,
+        nics.broadcast_uri broadcast_uri,
+        nics.isolation_uri isolation_uri,
+        vpc.id vpc_id,
+        vpc.uuid vpc_uuid,
+        networks.uuid network_uuid,
+        networks.traffic_type traffic_type,
+        networks.guest_type guest_type,
+        user_ip_address.id public_ip_id,
+        user_ip_address.uuid public_ip_uuid,
+        user_ip_address.public_ip_address public_ip_address,
+        ssh_keypairs.keypair_name keypair_name,
+        resource_tags.id tag_id,
+        resource_tags.uuid tag_uuid,
+        resource_tags.key tag_key,
+        resource_tags.value tag_value,
+        resource_tags.domain_id tag_domain_id,
+        resource_tags.account_id tag_account_id,
+        resource_tags.resource_id tag_resource_id,
+        resource_tags.resource_uuid tag_resource_uuid,
+        resource_tags.resource_type tag_resource_type,
+        resource_tags.customer tag_customer,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`user_vm`
+            inner join
+        `cloud`.`vm_instance` ON vm_instance.id = user_vm.id
+            and vm_instance.removed is NULL
+            inner join
+        `cloud`.`account` ON vm_instance.account_id = account.id
+            inner join
+        `cloud`.`domain` ON vm_instance.domain_id = domain.id
+            left join
+        `cloud`.`guest_os` ON vm_instance.guest_os_id = guest_os.id
+            left join
+        `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = account.id
+            left join
+        `cloud`.`instance_group_vm_map` ON vm_instance.id = instance_group_vm_map.instance_id
+            left join
+        `cloud`.`instance_group` ON instance_group_vm_map.group_id = instance_group.id
+            left join
+        `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+            left join
+        `cloud`.`host` ON vm_instance.host_id = host.id
+            left join
+        `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+--            left join
+--        `cloud`.`vm_template iso` ON iso.id = user_vm.iso_id
+            left join
+        `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+            left join
+        `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+            left join
+        `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
+            left join
+        `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+            left join
+        `cloud`.`security_group_vm_map` ON vm_instance.id = security_group_vm_map.instance_id
+            left join
+        `cloud`.`security_group` ON security_group_vm_map.security_group_id = security_group.id
+            left join
+        `cloud`.`nics` ON vm_instance.id = nics.instance_id
+            left join
+        `cloud`.`networks` ON nics.network_id = networks.id
+            left join
+        `cloud`.`vpc` ON networks.vpc_id = vpc.id
+            left join
+        `cloud`.`user_ip_address` ON user_ip_address.vm_id = vm_instance.id
+            left join
+        `cloud`.`user_vm_details` ON user_vm_details.vm_id = vm_instance.id
+            and user_vm_details.name = 'SSH.PublicKey'
+            left join
+        `cloud`.`ssh_keypairs` ON ssh_keypairs.public_key = user_vm_details.value
+            left join
+        `cloud`.`resource_tags` ON resource_tags.resource_id = vm_instance.id
+            and resource_tags.resource_type = 'UserVm'
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+            and async_job.instance_type = 'VirtualMachine'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
-CREATE VIEW domain_router_view AS
-select
-vm_instance.id id,
-vm_instance.name name,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-vm_instance.uuid uuid,
-vm_instance.created created,
-vm_instance.state state,
-vm_instance.removed removed,
-vm_instance.pod_id pod_id,
-vm_instance.instance_name instance_name,
-host_pod_ref.uuid pod_uuid,
-data_center.id data_center_id,
-data_center.uuid data_center_uuid,
-data_center.name data_center_name,
-data_center.dns1 dns1,
-data_center.dns2 dns2,
-host.id host_id,
-host.uuid host_uuid,
-host.name host_name,
-vm_template.id template_id,
-vm_template.uuid template_uuid,
-service_offering.id service_offering_id,
-disk_offering.uuid service_offering_uuid,
-disk_offering.name service_offering_name,
-nics.id nic_id,
-nics.uuid nic_uuid,
-nics.network_id network_id,
-nics.ip4_address ip_address,
-nics.default_nic is_default_nic,
-nics.gateway gateway,
-nics.netmask netmask,
-nics.mac_address mac_address,
-nics.broadcast_uri broadcast_uri,
-nics.isolation_uri isolation_uri,
-vpc.id vpc_id,
-vpc.uuid vpc_uuid,
-networks.uuid network_uuid,
-networks.name network_name,
-networks.network_domain network_domain,
-networks.traffic_type traffic_type,
-networks.guest_type guest_type,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id,
-domain_router.template_version template_version,
-domain_router.scripts_version scripts_version,
-domain_router.is_redundant_router is_redundant_router,
-domain_router.redundant_state redundant_state,
-domain_router.stop_pending stop_pending
-from domain_router
-inner join vm_instance on vm_instance.id = domain_router.id
-inner join account on vm_instance.account_id=account.id
-inner join domain on vm_instance.domain_id=domain.id
-left join host_pod_ref on vm_instance.pod_id = host_pod_ref.id
-left join projects on projects.project_account_id = account.id
-left join data_center on vm_instance.data_center_id=data_center.id
-left join host on vm_instance.host_id=host.id
-left join vm_template on vm_instance.vm_template_id=vm_template.id
-left join service_offering on vm_instance.service_offering_id=service_offering.id
-left join disk_offering  on vm_instance.service_offering_id=disk_offering.id
-left join volumes on vm_instance.id=volumes.instance_id
-left join storage_pool on volumes.pool_id=storage_pool.id
-left join nics on vm_instance.id=nics.instance_id
-left join networks on nics.network_id=networks.id
-left join vpc on networks.vpc_id = vpc.id
-left join async_job on async_job.instance_id = vm_instance.id and async_job.instance_type = "DomainRouter" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`domain_router_view` AS
+    select 
+        vm_instance.id id,
+        vm_instance.name name,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        vm_instance.uuid uuid,
+        vm_instance.created created,
+        vm_instance.state state,
+        vm_instance.removed removed,
+        vm_instance.pod_id pod_id,
+        vm_instance.instance_name instance_name,
+        host_pod_ref.uuid pod_uuid,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        data_center.dns1 dns1,
+        data_center.dns2 dns2,
+        host.id host_id,
+        host.uuid host_uuid,
+        host.name host_name,
+        vm_template.id template_id,
+        vm_template.uuid template_uuid,
+        service_offering.id service_offering_id,
+        disk_offering.uuid service_offering_uuid,
+        disk_offering.name service_offering_name,
+        nics.id nic_id,
+        nics.uuid nic_uuid,
+        nics.network_id network_id,
+        nics.ip4_address ip_address,
+        nics.default_nic is_default_nic,
+        nics.gateway gateway,
+        nics.netmask netmask,
+        nics.mac_address mac_address,
+        nics.broadcast_uri broadcast_uri,
+        nics.isolation_uri isolation_uri,
+        vpc.id vpc_id,
+        vpc.uuid vpc_uuid,
+        networks.uuid network_uuid,
+        networks.name network_name,
+        networks.network_domain network_domain,
+        networks.traffic_type traffic_type,
+        networks.guest_type guest_type,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id,
+        domain_router.template_version template_version,
+        domain_router.scripts_version scripts_version,
+        domain_router.is_redundant_router is_redundant_router,
+        domain_router.redundant_state redundant_state,
+        domain_router.stop_pending stop_pending
+    from
+        `cloud`.`domain_router`
+            inner join
+        `cloud`.`vm_instance` ON vm_instance.id = domain_router.id
+            inner join
+        `cloud`.`account` ON vm_instance.account_id = account.id
+            inner join
+        `cloud`.`domain` ON vm_instance.domain_id = domain.id
+            left join
+        `cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = account.id
+            left join
+        `cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
+            left join
+        `cloud`.`host` ON vm_instance.host_id = host.id
+            left join
+        `cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
+            left join
+        `cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
+            left join
+        `cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
+            left join
+        `cloud`.`volumes` ON vm_instance.id = volumes.instance_id
+            left join
+        `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+            left join
+        `cloud`.`nics` ON vm_instance.id = nics.instance_id
+            left join
+        `cloud`.`networks` ON nics.network_id = networks.id
+            left join
+        `cloud`.`vpc` ON networks.vpc_id = vpc.id
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = vm_instance.id
+            and async_job.instance_type = 'DomainRouter'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`security_group_view`;
-CREATE VIEW security_group_view AS
-select
-security_group.id id,
-security_group.name name,
-security_group.description description,
-security_group.uuid uuid,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-security_group_rule.id rule_id,
-security_group_rule.uuid rule_uuid,
-security_group_rule.type rule_type,
-security_group_rule.start_port rule_start_port,
-security_group_rule.end_port rule_end_port,
-security_group_rule.protocol rule_protocol,
-security_group_rule.allowed_network_id rule_allowed_network_id,
-security_group_rule.allowed_ip_cidr rule_allowed_ip_cidr,
-security_group_rule.create_status rule_create_status,
-resource_tags.id tag_id,
-resource_tags.uuid tag_uuid,
-resource_tags.key tag_key,
-resource_tags.value tag_value,
-resource_tags.domain_id tag_domain_id,
-resource_tags.account_id tag_account_id,
-resource_tags.resource_id tag_resource_id,
-resource_tags.resource_uuid tag_resource_uuid,
-resource_tags.resource_type tag_resource_type,
-resource_tags.customer tag_customer,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from security_group
-left join security_group_rule on security_group.id = security_group_rule.security_group_id
-inner join account on security_group.account_id=account.id
-inner join domain on security_group.domain_id=domain.id
-left join projects on projects.project_account_id = security_group.account_id
-left join resource_tags on resource_tags.resource_id = security_group.id and resource_tags.resource_type = "SecurityGroup"
-left join async_job on async_job.instance_id = security_group.id and async_job.instance_type = "SecurityGroup" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`security_group_view` AS
+    select 
+        security_group.id id,
+        security_group.name name,
+        security_group.description description,
+        security_group.uuid uuid,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        security_group_rule.id rule_id,
+        security_group_rule.uuid rule_uuid,
+        security_group_rule.type rule_type,
+        security_group_rule.start_port rule_start_port,
+        security_group_rule.end_port rule_end_port,
+        security_group_rule.protocol rule_protocol,
+        security_group_rule.allowed_network_id rule_allowed_network_id,
+        security_group_rule.allowed_ip_cidr rule_allowed_ip_cidr,
+        security_group_rule.create_status rule_create_status,
+        resource_tags.id tag_id,
+        resource_tags.uuid tag_uuid,
+        resource_tags.key tag_key,
+        resource_tags.value tag_value,
+        resource_tags.domain_id tag_domain_id,
+        resource_tags.account_id tag_account_id,
+        resource_tags.resource_id tag_resource_id,
+        resource_tags.resource_uuid tag_resource_uuid,
+        resource_tags.resource_type tag_resource_type,
+        resource_tags.customer tag_customer,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`security_group`
+            left join
+        `cloud`.`security_group_rule` ON security_group.id = security_group_rule.security_group_id
+            inner join
+        `cloud`.`account` ON security_group.account_id = account.id
+            inner join
+        `cloud`.`domain` ON security_group.domain_id = domain.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = security_group.account_id
+            left join
+        `cloud`.`resource_tags` ON resource_tags.resource_id = security_group.id
+            and resource_tags.resource_type = 'SecurityGroup'
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = security_group.id
+            and async_job.instance_type = 'SecurityGroup'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`resource_tag_view`;
-CREATE VIEW resource_tag_view AS
-select
-resource_tags.id,
-resource_tags.uuid,
-resource_tags.key,
-resource_tags.value,
-resource_tags.resource_id,
-resource_tags.resource_uuid,
-resource_tags.resource_type,
-resource_tags.customer,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name
-from resource_tags
-inner join account on resource_tags.account_id=account.id
-inner join domain on resource_tags.domain_id=domain.id
-left join projects on projects.project_account_id = resource_tags.account_id;
+CREATE VIEW `cloud`.`resource_tag_view` AS
+    select 
+        resource_tags.id,
+        resource_tags.uuid,
+        resource_tags.key,
+        resource_tags.value,
+        resource_tags.resource_id,
+        resource_tags.resource_uuid,
+        resource_tags.resource_type,
+        resource_tags.customer,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name
+    from
+        `cloud`.`resource_tags`
+            inner join
+        `cloud`.`account` ON resource_tags.account_id = account.id
+            inner join
+        `cloud`.`domain` ON resource_tags.domain_id = domain.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = resource_tags.account_id;
 
 
 DROP VIEW IF EXISTS `cloud`.`event_view`;
-CREATE VIEW event_view AS
-select
-event.id,
-event.uuid,
-event.type,
-event.state,
-event.description,
-event.created,
-event.level,
-event.parameters,
-event.start_id,
-eve.uuid start_uuid,
-event.user_id,
-user.username user_name,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name
-from event
-inner join account on event.account_id=account.id
-inner join domain on event.domain_id=domain.id
-inner join user on event.user_id = user.id
-left join projects on projects.project_account_id = event.account_id
-left join event eve on event.start_id = eve.id;
+CREATE VIEW `cloud`.`event_view` AS
+    select 
+        event.id,
+        event.uuid,
+        event.type,
+        event.state,
+        event.description,
+        event.created,
+        event.level,
+        event.parameters,
+        event.start_id,
+        eve.uuid start_uuid,
+        event.user_id,
+        user.username user_name,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name
+    from
+        `cloud`.`event`
+            inner join
+        `cloud`.`account` ON event.account_id = account.id
+            inner join
+        `cloud`.`domain` ON event.domain_id = domain.id
+            inner join
+        `cloud`.`user` ON event.user_id = user.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = event.account_id
+            left join
+        `cloud`.`event` eve ON event.start_id = eve.id;
 
 DROP VIEW IF EXISTS `cloud`.`instance_group_view`;
-CREATE VIEW instance_group_view AS
-select
-instance_group.id,
-instance_group.uuid,
-instance_group.name,
-instance_group.removed,
-instance_group.created,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name
-from instance_group
-inner join account on instance_group.account_id=account.id
-inner join domain on account.domain_id=domain.id
-left join projects on projects.project_account_id = instance_group.account_id;
+CREATE VIEW `cloud`.`instance_group_view` AS
+    select 
+        instance_group.id,
+        instance_group.uuid,
+        instance_group.name,
+        instance_group.removed,
+        instance_group.created,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name
+    from
+        `cloud`.`instance_group`
+            inner join
+        `cloud`.`account` ON instance_group.account_id = account.id
+            inner join
+        `cloud`.`domain` ON account.domain_id = domain.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = instance_group.account_id;
 
 DROP VIEW IF EXISTS `cloud`.`user_view`;
-CREATE VIEW user_view AS
-select 
-user.id,
-user.uuid,
-user.username,
-user.password,
-user.firstname,
-user.lastname,
-user.email,
-user.state,
-user.api_key,
-user.secret_key,
-user.created,
-user.removed,
-user.timezone,
-user.registration_token,
-user.is_registered,
-user.incorrect_login_attempts,
-account.id account_id, 
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from user 
-inner join account on user.account_id = account.id
-inner join domain on account.domain_id=domain.id
-left join async_job on async_job.instance_id = user.id and async_job.instance_type = "User" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`user_view` AS
+    select 
+        user.id,
+        user.uuid,
+        user.username,
+        user.password,
+        user.firstname,
+        user.lastname,
+        user.email,
+        user.state,
+        user.api_key,
+        user.secret_key,
+        user.created,
+        user.removed,
+        user.timezone,
+        user.registration_token,
+        user.is_registered,
+        user.incorrect_login_attempts,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`user`
+            inner join
+        `cloud`.`account` ON user.account_id = account.id
+            inner join
+        `cloud`.`domain` ON account.domain_id = domain.id
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = user.id
+            and async_job.instance_type = 'User'
+            and async_job.job_status = 0;
 
 
 DROP VIEW IF EXISTS `cloud`.`project_view`;
-CREATE VIEW project_view AS
-select
-projects.id,
-projects.uuid,
-projects.name,
-projects.display_text,
-projects.state,
-projects.removed,
-projects.created,
-account.account_name owner,
-pacct.account_id,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path,
-resource_tags.id tag_id,
-resource_tags.uuid tag_uuid,
-resource_tags.key tag_key,
-resource_tags.value tag_value,
-resource_tags.domain_id tag_domain_id,
-resource_tags.account_id tag_account_id,
-resource_tags.resource_id tag_resource_id,
-resource_tags.resource_uuid tag_resource_uuid,
-resource_tags.resource_type tag_resource_type,
-resource_tags.customer tag_customer
-from projects
-inner join domain on projects.domain_id=domain.id
-inner join project_account on projects.id = project_account.project_id and project_account.account_role = "Admin"
-inner join account on account.id = project_account.account_id
-left join resource_tags on resource_tags.resource_id = projects.id and resource_tags.resource_type = "Project"
-left join project_account pacct on projects.id = pacct.project_id;
+CREATE VIEW `cloud`.`project_view` AS
+    select 
+        projects.id,
+        projects.uuid,
+        projects.name,
+        projects.display_text,
+        projects.state,
+        projects.removed,
+        projects.created,
+        account.account_name owner,
+        pacct.account_id,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        resource_tags.id tag_id,
+        resource_tags.uuid tag_uuid,
+        resource_tags.key tag_key,
+        resource_tags.value tag_value,
+        resource_tags.domain_id tag_domain_id,
+        resource_tags.account_id tag_account_id,
+        resource_tags.resource_id tag_resource_id,
+        resource_tags.resource_uuid tag_resource_uuid,
+        resource_tags.resource_type tag_resource_type,
+        resource_tags.customer tag_customer
+    from
+        `cloud`.`projects`
+            inner join
+        `cloud`.`domain` ON projects.domain_id = domain.id
+            inner join
+        `cloud`.`project_account` ON projects.id = project_account.project_id
+            and project_account.account_role = 'Admin'
+            inner join
+        `cloud`.`account` ON account.id = project_account.account_id
+            left join
+        `cloud`.`resource_tags` ON resource_tags.resource_id = projects.id
+            and resource_tags.resource_type = 'Project'
+            left join
+        `cloud`.`project_account` pacct ON projects.id = pacct.project_id;
 
 DROP VIEW IF EXISTS `cloud`.`project_account_view`;
-CREATE VIEW project_account_view AS
-select
-project_account.id,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name,
-account.type account_type,
-project_account.account_role,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path
-from project_account
-inner join account on project_account.account_id = account.id
-inner join domain on account.domain_id=domain.id
-inner join projects on projects.id = project_account.project_id;
+CREATE VIEW `cloud`.`project_account_view` AS
+    select 
+        project_account.id,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name,
+        account.type account_type,
+        project_account.account_role,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path
+    from
+        `cloud`.`project_account`
+            inner join
+        `cloud`.`account` ON project_account.account_id = account.id
+            inner join
+        `cloud`.`domain` ON account.domain_id = domain.id
+            inner join
+        `cloud`.`projects` ON projects.id = project_account.project_id;
 
 DROP VIEW IF EXISTS `cloud`.`project_invitation_view`;
-CREATE VIEW project_invitation_view AS
-select
-project_invitations.id,
-project_invitations.uuid,
-project_invitations.email,
-project_invitations.created,
-project_invitations.state,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-account.id account_id,
-account.uuid account_uuid,
-account.account_name,
-account.type account_type,
-domain.id domain_id,
-domain.uuid domain_uuid,
-domain.name domain_name,
-domain.path domain_path
-from project_invitations
-left join account on project_invitations.account_id = account.id
-left join domain on project_invitations.domain_id=domain.id
-left join projects on projects.id = project_invitations.project_id;
+CREATE VIEW `cloud`.`project_invitation_view` AS
+    select 
+        project_invitations.id,
+        project_invitations.uuid,
+        project_invitations.email,
+        project_invitations.created,
+        project_invitations.state,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path
+    from
+        `cloud`.`project_invitations`
+            left join
+        `cloud`.`account` ON project_invitations.account_id = account.id
+            left join
+        `cloud`.`domain` ON project_invitations.domain_id = domain.id
+            left join
+        `cloud`.`projects` ON projects.id = project_invitations.project_id;
 
 DROP VIEW IF EXISTS `cloud`.`host_view`;
-CREATE VIEW host_view AS
-select 
-host.id,
-host.uuid,
-host.name,
-host.status,
-host.disconnected,
-host.type,
-host.private_ip_address,
-host.version,
-host.hypervisor_type,
-host.hypervisor_version,
-host.capabilities,
-host.last_ping,
-host.created,
-host.removed,
-host.resource_state,
-host.mgmt_server_id,
-host.cpus,
-host.speed,
-host.ram,
-cluster.id cluster_id,
-cluster.uuid cluster_uuid,
-cluster.name cluster_name,
-cluster.cluster_type,
-data_center.id data_center_id, 
-data_center.uuid data_center_uuid,
-data_center.name data_center_name, 
-host_pod_ref.id pod_id, 
-host_pod_ref.uuid pod_uuid,
-host_pod_ref.name pod_name,
-host_tags.tag,
-guest_os_category.id guest_os_category_id,
-guest_os_category.uuid guest_os_category_uuid,
-guest_os_category.name guest_os_category_name,
-mem_caps.used_capacity memory_used_capacity,
-mem_caps.reserved_capacity memory_reserved_capacity,
-cpu_caps.used_capacity cpu_used_capacity,
-cpu_caps.reserved_capacity cpu_reserved_capacity,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from host 
-left join cluster on host.cluster_id = cluster.id
-left join data_center on host.data_center_id = data_center.id
-left join host_pod_ref on host.pod_id = host_pod_ref.id
-left join host_details on host.id = host_details.id and host_details.name = "guest.os.category.id"
-left join guest_os_category on guest_os_category.id = CONVERT( host_details.value, UNSIGNED )
-left join host_tags on host_tags.host_id = host.id
-left join op_host_capacity mem_caps on host.id = mem_caps.host_id and mem_caps.capacity_type = 0
-left join op_host_capacity cpu_caps on host.id = cpu_caps.host_id and cpu_caps.capacity_type = 1
-left join async_job on async_job.instance_id = host.id and async_job.instance_type = "Host" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`host_view` AS
+    select 
+        host.id,
+        host.uuid,
+        host.name,
+        host.status,
+        host.disconnected,
+        host.type,
+        host.private_ip_address,
+        host.version,
+        host.hypervisor_type,
+        host.hypervisor_version,
+        host.capabilities,
+        host.last_ping,
+        host.created,
+        host.removed,
+        host.resource_state,
+        host.mgmt_server_id,
+        host.cpus,
+        host.speed,
+        host.ram,
+        cluster.id cluster_id,
+        cluster.uuid cluster_uuid,
+        cluster.name cluster_name,
+        cluster.cluster_type,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        host_pod_ref.id pod_id,
+        host_pod_ref.uuid pod_uuid,
+        host_pod_ref.name pod_name,
+        host_tags.tag,
+        guest_os_category.id guest_os_category_id,
+        guest_os_category.uuid guest_os_category_uuid,
+        guest_os_category.name guest_os_category_name,
+        mem_caps.used_capacity memory_used_capacity,
+        mem_caps.reserved_capacity memory_reserved_capacity,
+        cpu_caps.used_capacity cpu_used_capacity,
+        cpu_caps.reserved_capacity cpu_reserved_capacity,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`host`
+            left join
+        `cloud`.`cluster` ON host.cluster_id = cluster.id
+            left join
+        `cloud`.`data_center` ON host.data_center_id = data_center.id
+            left join
+        `cloud`.`host_pod_ref` ON host.pod_id = host_pod_ref.id
+            left join
+        `cloud`.`host_details` ON host.id = host_details.id
+            and host_details.name = 'guest.os.category.id'
+            left join
+        `cloud`.`guest_os_category` ON guest_os_category.id = CONVERT( host_details.value , UNSIGNED)
+            left join
+        `cloud`.`host_tags` ON host_tags.host_id = host.id
+            left join
+        `cloud`.`op_host_capacity` mem_caps ON host.id = mem_caps.host_id
+            and mem_caps.capacity_type = 0
+            left join
+        `cloud`.`op_host_capacity` cpu_caps ON host.id = cpu_caps.host_id
+            and cpu_caps.capacity_type = 1
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = host.id
+            and async_job.instance_type = 'Host'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`volume_view`;
-CREATE VIEW volume_view AS
-select 
-volumes.id,
-volumes.uuid,
-volumes.name,
-volumes.device_id,
-volumes.volume_type,
-volumes.size,
-volumes.created,
-volumes.state,
-volumes.attached,
-volumes.removed,
-volumes.pod_id,
-account.id account_id, 
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path,
-projects.id project_id,
-projects.uuid project_uuid,
-projects.name project_name,
-data_center.id data_center_id, 
-data_center.uuid data_center_uuid,
-data_center.name data_center_name, 
-vm_instance.id vm_id,
-vm_instance.uuid vm_uuid,
-vm_instance.name vm_name,
-vm_instance.state vm_state,
-vm_instance.vm_type,
-user_vm.display_name vm_display_name,
-volume_host_ref.size volume_host_size,
-volume_host_ref.created volume_host_created,
-volume_host_ref.format,
-volume_host_ref.download_pct,
-volume_host_ref.download_state,
-volume_host_ref.error_str,
-disk_offering.id disk_offering_id,
-disk_offering.uuid disk_offering_uuid,
-disk_offering.name disk_offering_name,
-disk_offering.display_text disk_offering_display_text,
-disk_offering.use_local_storage,
-disk_offering.system_use,
-storage_pool.id pool_id,
-storage_pool.uuid pool_uuid,
-storage_pool.name pool_name,
-cluster.hypervisor_type,
-vm_template.id template_id,
-vm_template.uuid template_uuid,
-vm_template.extractable,
-vm_template.type template_type,
-resource_tags.id tag_id, 
-resource_tags.uuid tag_uuid,
-resource_tags.key tag_key,
-resource_tags.value tag_value,
-resource_tags.domain_id tag_domain_id, 
-resource_tags.account_id tag_account_id, 
-resource_tags.resource_id tag_resource_id, 
-resource_tags.resource_uuid tag_resource_uuid, 
-resource_tags.resource_type tag_resource_type, 
-resource_tags.customer tag_customer,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from volumes 
-inner join account on volumes.account_id=account.id 
-inner join domain on volumes.domain_id=domain.id
-left join projects on projects.project_account_id = account.id
-left join data_center on volumes.data_center_id = data_center.id
-left join vm_instance on volumes.instance_id = vm_instance.id
-left join user_vm on user_vm.id = vm_instance.id
-left join volume_host_ref on volumes.id = volume_host_ref.volume_id and volumes.data_center_id = volume_host_ref.zone_id
-left join disk_offering on volumes.disk_offering_id = disk_offering.id
-left join storage_pool on volumes.pool_id = storage_pool.id
-left join cluster on storage_pool.cluster_id = cluster.id
-left join vm_template on volumes.template_id = vm_template.id
-left join resource_tags on resource_tags.resource_id = volumes.id and resource_tags.resource_type = "Volume"
-left join async_job on async_job.instance_id = volumes.id and async_job.instance_type = "Volume" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`volume_view` AS
+    select 
+        volumes.id,
+        volumes.uuid,
+        volumes.name,
+        volumes.device_id,
+        volumes.volume_type,
+        volumes.size,
+        volumes.created,
+        volumes.state,
+        volumes.attached,
+        volumes.removed,
+        volumes.pod_id,
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        projects.id project_id,
+        projects.uuid project_uuid,
+        projects.name project_name,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        vm_instance.id vm_id,
+        vm_instance.uuid vm_uuid,
+        vm_instance.name vm_name,
+        vm_instance.state vm_state,
+        vm_instance.vm_type,
+        user_vm.display_name vm_display_name,
+        volume_host_ref.size volume_host_size,
+        volume_host_ref.created volume_host_created,
+        volume_host_ref.format,
+        volume_host_ref.download_pct,
+        volume_host_ref.download_state,
+        volume_host_ref.error_str,
+        disk_offering.id disk_offering_id,
+        disk_offering.uuid disk_offering_uuid,
+        disk_offering.name disk_offering_name,
+        disk_offering.display_text disk_offering_display_text,
+        disk_offering.use_local_storage,
+        disk_offering.system_use,
+        storage_pool.id pool_id,
+        storage_pool.uuid pool_uuid,
+        storage_pool.name pool_name,
+        cluster.hypervisor_type,
+        vm_template.id template_id,
+        vm_template.uuid template_uuid,
+        vm_template.extractable,
+        vm_template.type template_type,
+        resource_tags.id tag_id,
+        resource_tags.uuid tag_uuid,
+        resource_tags.key tag_key,
+        resource_tags.value tag_value,
+        resource_tags.domain_id tag_domain_id,
+        resource_tags.account_id tag_account_id,
+        resource_tags.resource_id tag_resource_id,
+        resource_tags.resource_uuid tag_resource_uuid,
+        resource_tags.resource_type tag_resource_type,
+        resource_tags.customer tag_customer,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`volumes`
+            inner join
+        `cloud`.`account` ON volumes.account_id = account.id
+            inner join
+        `cloud`.`domain` ON volumes.domain_id = domain.id
+            left join
+        `cloud`.`projects` ON projects.project_account_id = account.id
+            left join
+        `cloud`.`data_center` ON volumes.data_center_id = data_center.id
+            left join
+        `cloud`.`vm_instance` ON volumes.instance_id = vm_instance.id
+            left join
+        `cloud`.`user_vm` ON user_vm.id = vm_instance.id
+            left join
+        `cloud`.`volume_host_ref` ON volumes.id = volume_host_ref.volume_id
+            and volumes.data_center_id = volume_host_ref.zone_id
+            left join
+        `cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id
+            left join
+        `cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
+            left join
+        `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
+            left join
+        `cloud`.`vm_template` ON volumes.template_id = vm_template.id
+            left join
+        `cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id
+            and resource_tags.resource_type = 'Volume'
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = volumes.id
+            and async_job.instance_type = 'Volume'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;
-CREATE VIEW account_netstats_view AS
-SELECT account_id, 
-sum(net_bytes_received)+ sum(current_bytes_received) as bytesReceived,
-sum(net_bytes_sent)+ sum(current_bytes_sent) as bytesSent
-FROM user_statistics
-group by account_id;
+CREATE VIEW `cloud`.`account_netstats_view` AS
+    SELECT 
+        account_id,
+        sum(net_bytes_received) + sum(current_bytes_received) as bytesReceived,
+        sum(net_bytes_sent) + sum(current_bytes_sent) as bytesSent
+    FROM
+        `cloud`.`user_statistics`
+    group by account_id;
 
 
 DROP VIEW IF EXISTS `cloud`.`account_vmstats_view`;
-CREATE VIEW account_vmstats_view AS
-SELECT account_id, state, count(*) as vmcount
-from vm_instance
-group by account_id, state;
+CREATE VIEW `cloud`.`account_vmstats_view` AS
+    SELECT 
+        account_id, state, count(*) as vmcount
+    from
+        `cloud`.`vm_instance`
+    group by account_id , state;
 
 DROP VIEW IF EXISTS `cloud`.`free_ip_view`;
-CREATE VIEW free_ip_view AS
-select count(user_ip_address.id) free_ip
-from user_ip_address
-inner join vlan on vlan.id = user_ip_address.vlan_db_id and vlan.vlan_type = "VirtualNetwork"
-where state = "Free"
+CREATE VIEW `cloud`.`free_ip_view` AS
+    select 
+        count(user_ip_address.id) free_ip
+    from
+        `cloud`.`user_ip_address`
+            inner join
+        `cloud`.`vlan` ON vlan.id = user_ip_address.vlan_db_id
+            and vlan.vlan_type = 'VirtualNetwork'
+    where
+        state = 'Free';
 
 DROP VIEW IF EXISTS `cloud`.`account_view`;
-CREATE VIEW account_view AS
-select 
-account.id,
-account.uuid,
-account.account_name,
-account.type,
-account.state,
-account.removed,
-account.cleanup_needed,
-account.network_domain,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path,
-data_center.id data_center_id,
-data_center.uuid data_center_uuid,
-data_center.name data_center_name,
-account_netstats_view.bytesReceived,
-account_netstats_view.bytesSent,
-vmlimit.max vmLimit,
-vmcount.count vmTotal,
-runningvm.vmcount runningVms,
-stoppedvm.vmcount stoppedVms,
-iplimit.max ipLimit,
-ipcount.count ipTotal,
-free_ip_view.free_ip ipFree,
-volumelimit.max volumeLimit,
-volumecount.count volumeTotal,
-snapshotlimit.max snapshotLimit,
-snapshotcount.count snapshotTotal,
-templatelimit.max templateLimit,
-templatecount.count templateTotal,
-vpclimit.max vpcLimit,
-vpccount.count vpcTotal,
-projectlimit.max projectLimit,
-projectcount.count projectTotal,
-networklimit.max networkLimit,
-networkcount.count networkTotal,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from free_ip_view, account 
-inner join domain on account.domain_id=domain.id
-left join data_center on account.default_zone_id = data_center.id
-left join account_netstats_view on account.id = account_netstats_view.account_id
-left join resource_limit vmlimit on account.id = vmlimit.account_id and vmlimit.type = "user_vm"
-left join resource_count vmcount on account.id = vmcount.account_id and vmcount.type = "user_vm"
-left join account_vmstats_view runningvm on account.id = runningvm.account_id and runningvm.state = "Running"
-left join account_vmstats_view stoppedvm on account.id = stoppedvm.account_id and stoppedvm.state = "Stopped"
-left join resource_limit iplimit on account.id = iplimit.account_id and iplimit.type = "public_ip"
-left join resource_count ipcount on account.id = ipcount.account_id and ipcount.type = "public_ip"
-left join resource_limit volumelimit on account.id = volumelimit.account_id and volumelimit.type = "volume"
-left join resource_count volumecount on account.id = volumecount.account_id and volumecount.type = "volume"
-left join resource_limit snapshotlimit on account.id = snapshotlimit.account_id and snapshotlimit.type = "snapshot"
-left join resource_count snapshotcount on account.id = snapshotcount.account_id and snapshotcount.type = "snapshot"
-left join resource_limit templatelimit on account.id = templatelimit.account_id and templatelimit.type = "template"
-left join resource_count templatecount on account.id = templatecount.account_id and templatecount.type = "template"
-left join resource_limit vpclimit on account.id = vpclimit.account_id and vpclimit.type = "vpc"
-left join resource_count vpccount on account.id = vpccount.account_id and vpccount.type = "vpc"
-left join resource_limit projectlimit on account.id = projectlimit.account_id and projectlimit.type = "project"
-left join resource_count projectcount on account.id = projectcount.account_id and projectcount.type = "project"
-left join resource_limit networklimit on account.id = networklimit.account_id and networklimit.type = "network"
-left join resource_count networkcount on account.id = networkcount.account_id and networkcount.type = "network"
-left join async_job on async_job.instance_id = account.id and async_job.instance_type = "Account" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`account_view` AS
+    select 
+        account.id,
+        account.uuid,
+        account.account_name,
+        account.type,
+        account.state,
+        account.removed,
+        account.cleanup_needed,
+        account.network_domain,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        account_netstats_view.bytesReceived,
+        account_netstats_view.bytesSent,
+        vmlimit.max vmLimit,
+        vmcount.count vmTotal,
+        runningvm.vmcount runningVms,
+        stoppedvm.vmcount stoppedVms,
+        iplimit.max ipLimit,
+        ipcount.count ipTotal,
+        free_ip_view.free_ip ipFree,
+        volumelimit.max volumeLimit,
+        volumecount.count volumeTotal,
+        snapshotlimit.max snapshotLimit,
+        snapshotcount.count snapshotTotal,
+        templatelimit.max templateLimit,
+        templatecount.count templateTotal,
+        vpclimit.max vpcLimit,
+        vpccount.count vpcTotal,
+        projectlimit.max projectLimit,
+        projectcount.count projectTotal,
+        networklimit.max networkLimit,
+        networkcount.count networkTotal,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`free_ip_view`,
+        `cloud`.`account`
+            inner join
+        `cloud`.`domain` ON account.domain_id = domain.id
+            left join
+        `cloud`.`data_center` ON account.default_zone_id = data_center.id
+            left join
+        `cloud`.`account_netstats_view` ON account.id = account_netstats_view.account_id
+            left join
+        `cloud`.`resource_limit` vmlimit ON account.id = vmlimit.account_id
+            and vmlimit.type = 'user_vm'
+            left join
+        `cloud`.`resource_count` vmcount ON account.id = vmcount.account_id
+            and vmcount.type = 'user_vm'
+            left join
+        `cloud`.`account_vmstats_view` runningvm ON account.id = runningvm.account_id
+            and runningvm.state = 'Running'
+            left join
+        `cloud`.`account_vmstats_view` stoppedvm ON account.id = stoppedvm.account_id
+            and stoppedvm.state = 'Stopped'
+            left join
+        `cloud`.`resource_limit` iplimit ON account.id = iplimit.account_id
+            and iplimit.type = 'public_ip'
+            left join
+        `cloud`.`resource_count` ipcount ON account.id = ipcount.account_id
+            and ipcount.type = 'public_ip'
+            left join
+        `cloud`.`resource_limit` volumelimit ON account.id = volumelimit.account_id
+            and volumelimit.type = 'volume'
+            left join
+        `cloud`.`resource_count` volumecount ON account.id = volumecount.account_id
+            and volumecount.type = 'volume'
+            left join
+        `cloud`.`resource_limit` snapshotlimit ON account.id = snapshotlimit.account_id
+            and snapshotlimit.type = 'snapshot'
+            left join
+        `cloud`.`resource_count` snapshotcount ON account.id = snapshotcount.account_id
+            and snapshotcount.type = 'snapshot'
+            left join
+        `cloud`.`resource_limit` templatelimit ON account.id = templatelimit.account_id
+            and templatelimit.type = 'template'
+            left join
+        `cloud`.`resource_count` templatecount ON account.id = templatecount.account_id
+            and templatecount.type = 'template'
+            left join
+        `cloud`.`resource_limit` vpclimit ON account.id = vpclimit.account_id
+            and vpclimit.type = 'vpc'
+            left join
+        `cloud`.`resource_count` vpccount ON account.id = vpccount.account_id
+            and vpccount.type = 'vpc'
+            left join
+        `cloud`.`resource_limit` projectlimit ON account.id = projectlimit.account_id
+            and projectlimit.type = 'project'
+            left join
+        `cloud`.`resource_count` projectcount ON account.id = projectcount.account_id
+            and projectcount.type = 'project'
+            left join
+        `cloud`.`resource_limit` networklimit ON account.id = networklimit.account_id
+            and networklimit.type = 'network'
+            left join
+        `cloud`.`resource_count` networkcount ON account.id = networkcount.account_id
+            and networkcount.type = 'network'
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = account.id
+            and async_job.instance_type = 'Account'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`async_job_view`;
-CREATE VIEW async_job_view AS
-select 
-account.id account_id, 
-account.uuid account_uuid,
-account.account_name account_name,
-account.type account_type,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path,
-user.id user_id,
-user.uuid user_uuid,
-async_job.id,
-async_job.uuid,
-async_job.job_cmd,
-async_job.job_status,
-async_job.job_process_status,
-async_job.job_result_code,
-async_job.job_result,
-async_job.created,
-async_job.removed,
-async_job.instance_type,
-async_job.instance_id,
-CASE 
-WHEN async_job.instance_type = 'Volume' THEN volumes.uuid 
-WHEN async_job.instance_type = 'Template' or async_job.instance_type = 'Iso' THEN vm_template.uuid
-WHEN async_job.instance_type = 'VirtualMachine' or async_job.instance_type = 'ConsoleProxy' or async_job.instance_type = 'SystemVm' or async_job.instance_type = 'DomainRouter' THEN vm_instance.uuid 
-WHEN async_job.instance_type = 'Snapshot' THEN snapshots.uuid 
-WHEN async_job.instance_type = 'Host' THEN host.uuid 
-WHEN async_job.instance_type = 'StoragePool' THEN storage_pool.uuid 
-WHEN async_job.instance_type = 'IpAddress' THEN user_ip_address.uuid 
-WHEN async_job.instance_type = 'SecurityGroup' THEN security_group.uuid 
-WHEN async_job.instance_type = 'PhysicalNetwork' THEN physical_network.uuid 
-WHEN async_job.instance_type = 'TrafficType' THEN physical_network_traffic_types.uuid 
-WHEN async_job.instance_type = 'PhysicalNetworkServiceProvider' THEN physical_network_service_providers.uuid
-WHEN async_job.instance_type = 'FirewallRule' THEN firewall_rules.uuid
-WHEN async_job.instance_type = 'Account' THEN acct.uuid
-WHEN async_job.instance_type = 'User' THEN us.uuid
-WHEN async_job.instance_type = 'StaticRoute' THEN static_routes.uuid
-WHEN async_job.instance_type = 'PrivateGateway' THEN vpc_gateways.uuid
-WHEN async_job.instance_type = 'Counter' THEN counter.uuid
-WHEN async_job.instance_type = 'Condition' THEN conditions.uuid
-WHEN async_job.instance_type = 'AutoScalePolicy' THEN autoscale_policies.uuid
-WHEN async_job.instance_type = 'AutoScaleVmProfile' THEN autoscale_vmprofiles.uuid
-WHEN async_job.instance_type = 'AutoScaleVmGroup' THEN autoscale_vmgroups.uuid
-ELSE null
-END instance_uuid
-from async_job
-left join account on async_job.account_id = account.id
-left join domain on domain.id = account.domain_id
-left join user on async_job.user_id = user.id
-left join volumes on async_job.instance_id = volumes.id
-left join vm_template on async_job.instance_id = vm_template.id
-left join vm_instance on async_job.instance_id = vm_instance.id
-left join snapshots on async_job.instance_id = snapshots.id
-left join host on async_job.instance_id = host.id
-left join storage_pool on async_job.instance_id = storage_pool.id
-left join user_ip_address on async_job.instance_id = user_ip_address.id
-left join security_group on async_job.instance_id = security_group.id
-left join physical_network on async_job.instance_id = physical_network.id
-left join physical_network_traffic_types on async_job.instance_id = physical_network_traffic_types.id
-left join physical_network_service_providers on async_job.instance_id = physical_network_service_providers.id
-left join firewall_rules on async_job.instance_id = firewall_rules.id
-left join account acct on async_job.instance_id = acct.id
-left join user us on async_job.instance_id = us.id
-left join static_routes on async_job.instance_id = static_routes.id
-left join vpc_gateways on async_job.instance_id = vpc_gateways.id
-left join counter on async_job.instance_id = counter.id
-left join conditions on async_job.instance_id = conditions.id
-left join autoscale_policies on async_job.instance_id = autoscale_policies.id
-left join autoscale_vmprofiles on async_job.instance_id = autoscale_vmprofiles.id
-left join autoscale_vmgroups on async_job.instance_id = autoscale_vmgroups.id;
+CREATE VIEW `cloud`.`async_job_view` AS
+    select 
+        account.id account_id,
+        account.uuid account_uuid,
+        account.account_name account_name,
+        account.type account_type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path,
+        user.id user_id,
+        user.uuid user_uuid,
+        async_job.id,
+        async_job.uuid,
+        async_job.job_cmd,
+        async_job.job_status,
+        async_job.job_process_status,
+        async_job.job_result_code,
+        async_job.job_result,
+        async_job.created,
+        async_job.removed,
+        async_job.instance_type,
+        async_job.instance_id,
+        CASE
+            WHEN async_job.instance_type = 'Volume' THEN volumes.uuid
+            WHEN
+                async_job.instance_type = 'Template'
+                    or async_job.instance_type = 'Iso'
+            THEN
+                vm_template.uuid
+            WHEN
+                async_job.instance_type = 'VirtualMachine'
+                    or async_job.instance_type = 'ConsoleProxy'
+                    or async_job.instance_type = 'SystemVm'
+                    or async_job.instance_type = 'DomainRouter'
+            THEN
+                vm_instance.uuid
+            WHEN async_job.instance_type = 'Snapshot' THEN snapshots.uuid
+            WHEN async_job.instance_type = 'Host' THEN host.uuid
+            WHEN async_job.instance_type = 'StoragePool' THEN storage_pool.uuid
+            WHEN async_job.instance_type = 'IpAddress' THEN user_ip_address.uuid
+            WHEN async_job.instance_type = 'SecurityGroup' THEN security_group.uuid
+            WHEN async_job.instance_type = 'PhysicalNetwork' THEN physical_network.uuid
+            WHEN async_job.instance_type = 'TrafficType' THEN physical_network_traffic_types.uuid
+            WHEN async_job.instance_type = 'PhysicalNetworkServiceProvider' THEN physical_network_service_providers.uuid
+            WHEN async_job.instance_type = 'FirewallRule' THEN firewall_rules.uuid
+            WHEN async_job.instance_type = 'Account' THEN acct.uuid
+            WHEN async_job.instance_type = 'User' THEN us.uuid
+            WHEN async_job.instance_type = 'StaticRoute' THEN static_routes.uuid
+            WHEN async_job.instance_type = 'PrivateGateway' THEN vpc_gateways.uuid
+            WHEN async_job.instance_type = 'Counter' THEN counter.uuid
+            WHEN async_job.instance_type = 'Condition' THEN conditions.uuid
+            WHEN async_job.instance_type = 'AutoScalePolicy' THEN autoscale_policies.uuid
+            WHEN async_job.instance_type = 'AutoScaleVmProfile' THEN autoscale_vmprofiles.uuid
+            WHEN async_job.instance_type = 'AutoScaleVmGroup' THEN autoscale_vmgroups.uuid
+            ELSE null
+        END instance_uuid
+    from
+        `cloud`.`async_job`
+            left join
+        `cloud`.`account` ON async_job.account_id = account.id
+            left join
+        `cloud`.`domain` ON domain.id = account.domain_id
+            left join
+        `cloud`.`user` ON async_job.user_id = user.id
+            left join
+        `cloud`.`volumes` ON async_job.instance_id = volumes.id
+            left join
+        `cloud`.`vm_template` ON async_job.instance_id = vm_template.id
+            left join
+        `cloud`.`vm_instance` ON async_job.instance_id = vm_instance.id
+            left join
+        `cloud`.`snapshots` ON async_job.instance_id = snapshots.id
+            left join
+        `cloud`.`host` ON async_job.instance_id = host.id
+            left join
+        `cloud`.`storage_pool` ON async_job.instance_id = storage_pool.id
+            left join
+        `cloud`.`user_ip_address` ON async_job.instance_id = user_ip_address.id
+            left join
+        `cloud`.`security_group` ON async_job.instance_id = security_group.id
+            left join
+        `cloud`.`physical_network` ON async_job.instance_id = physical_network.id
+            left join
+        `cloud`.`physical_network_traffic_types` ON async_job.instance_id = physical_network_traffic_types.id
+            left join
+        `cloud`.`physical_network_service_providers` ON async_job.instance_id = physical_network_service_providers.id
+            left join
+        `cloud`.`firewall_rules` ON async_job.instance_id = firewall_rules.id
+            left join
+        `cloud`.`account` acct ON async_job.instance_id = acct.id
+            left join
+        `cloud`.`user` us ON async_job.instance_id = us.id
+            left join
+        `cloud`.`static_routes` ON async_job.instance_id = static_routes.id
+            left join
+        `cloud`.`vpc_gateways` ON async_job.instance_id = vpc_gateways.id
+            left join
+        `cloud`.`counter` ON async_job.instance_id = counter.id
+            left join
+        `cloud`.`conditions` ON async_job.instance_id = conditions.id
+            left join
+        `cloud`.`autoscale_policies` ON async_job.instance_id = autoscale_policies.id
+            left join
+        `cloud`.`autoscale_vmprofiles` ON async_job.instance_id = autoscale_vmprofiles.id
+            left join
+        `cloud`.`autoscale_vmgroups` ON async_job.instance_id = autoscale_vmgroups.id;
 
 DROP VIEW IF EXISTS `cloud`.`storage_pool_view`;
-CREATE VIEW storage_pool_view AS
-select 
-storage_pool.id,
-storage_pool.uuid,
-storage_pool.name,
-storage_pool.status,
-storage_pool.path,
-storage_pool.pool_type,
-storage_pool.host_address,
-storage_pool.created,
-storage_pool.removed,
-storage_pool.capacity_bytes,
-cluster.id cluster_id,
-cluster.uuid cluster_uuid,
-cluster.name cluster_name,
-cluster.cluster_type,
-data_center.id data_center_id, 
-data_center.uuid data_center_uuid,
-data_center.name data_center_name, 
-host_pod_ref.id pod_id, 
-host_pod_ref.uuid pod_uuid,
-host_pod_ref.name pod_name,
-storage_pool_details.name tag,
-op_host_capacity.used_capacity disk_used_capacity,
-op_host_capacity.reserved_capacity disk_reserved_capacity,
-async_job.id job_id,
-async_job.uuid job_uuid,
-async_job.job_status job_status,
-async_job.account_id job_account_id
-from storage_pool 
-left join cluster on storage_pool.cluster_id = cluster.id
-left join data_center on storage_pool.data_center_id = data_center.id
-left join host_pod_ref on storage_pool.pod_id = host_pod_ref.id
-left join storage_pool_details on storage_pool_details.pool_id = storage_pool.id and storage_pool_details.value = 'true'
-left join op_host_capacity on storage_pool.id = op_host_capacity.host_id and op_host_capacity.capacity_type = 3
-left join async_job on async_job.instance_id = storage_pool.id and async_job.instance_type = "StoragePool" and async_job.job_status = 0;
+CREATE VIEW `cloud`.`storage_pool_view` AS
+    select 
+        storage_pool.id,
+        storage_pool.uuid,
+        storage_pool.name,
+        storage_pool.status,
+        storage_pool.path,
+        storage_pool.pool_type,
+        storage_pool.host_address,
+        storage_pool.created,
+        storage_pool.removed,
+        storage_pool.capacity_bytes,
+        cluster.id cluster_id,
+        cluster.uuid cluster_uuid,
+        cluster.name cluster_name,
+        cluster.cluster_type,
+        data_center.id data_center_id,
+        data_center.uuid data_center_uuid,
+        data_center.name data_center_name,
+        host_pod_ref.id pod_id,
+        host_pod_ref.uuid pod_uuid,
+        host_pod_ref.name pod_name,
+        storage_pool_details.name tag,
+        op_host_capacity.used_capacity disk_used_capacity,
+        op_host_capacity.reserved_capacity disk_reserved_capacity,
+        async_job.id job_id,
+        async_job.uuid job_uuid,
+        async_job.job_status job_status,
+        async_job.account_id job_account_id
+    from
+        `cloud`.`storage_pool`
+            left join
+        `cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
+            left join
+        `cloud`.`data_center` ON storage_pool.data_center_id = data_center.id
+            left join
+        `cloud`.`host_pod_ref` ON storage_pool.pod_id = host_pod_ref.id
+            left join
+        `cloud`.`storage_pool_details` ON storage_pool_details.pool_id = storage_pool.id
+            and storage_pool_details.value = 'true'
+            left join
+        `cloud`.`op_host_capacity` ON storage_pool.id = op_host_capacity.host_id
+            and op_host_capacity.capacity_type = 3
+            left join
+        `cloud`.`async_job` ON async_job.instance_id = storage_pool.id
+            and async_job.instance_type = 'StoragePool'
+            and async_job.job_status = 0;
 
 DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
-CREATE VIEW disk_offering_view AS
-select 
-disk_offering.id,
-disk_offering.uuid,
-disk_offering.name,
-disk_offering.display_text,
-disk_offering.disk_size,
-disk_offering.created,
-disk_offering.tags,
-disk_offering.customized,
-disk_offering.removed,
-disk_offering.use_local_storage,
-disk_offering.system_use,
-disk_offering.sort_key,
-disk_offering.type,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path
-from disk_offering 
-left join domain on disk_offering.domain_id=domain.id;
+CREATE VIEW `cloud`.`disk_offering_view` AS
+    select 
+        disk_offering.id,
+        disk_offering.uuid,
+        disk_offering.name,
+        disk_offering.display_text,
+        disk_offering.disk_size,
+        disk_offering.created,
+        disk_offering.tags,
+        disk_offering.customized,
+        disk_offering.removed,
+        disk_offering.use_local_storage,
+        disk_offering.system_use,
+        disk_offering.sort_key,
+        disk_offering.type,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path
+    from
+        `cloud`.`disk_offering`
+            left join
+        `cloud`.`domain` ON disk_offering.domain_id = domain.id;
 
 DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
-CREATE VIEW service_offering_view AS
-select 
-service_offering.id,
-disk_offering.uuid,
-disk_offering.name,
-disk_offering.display_text,
-disk_offering.created,
-disk_offering.tags,
-disk_offering.removed,
-disk_offering.use_local_storage,
-disk_offering.system_use,
-service_offering.cpu,
-service_offering.speed,
-service_offering.ram_size,
-service_offering.nw_rate,
-service_offering.mc_rate,
-service_offering.ha_enabled,
-service_offering.limit_cpu_use,
-service_offering.host_tag,
-service_offering.default_use,
-service_offering.vm_type,
-service_offering.sort_key,
-domain.id domain_id, 
-domain.uuid domain_uuid,
-domain.name domain_name, 
-domain.path domain_path
-from service_offering 
-inner join disk_offering on service_offering.id = disk_offering.id
-left join domain on disk_offering.domain_id=domain.id;
-
-
+CREATE VIEW `cloud`.`service_offering_view` AS
+    select 
+        service_offering.id,
+        disk_offering.uuid,
+        disk_offering.name,
+        disk_offering.display_text,
+        disk_offering.created,
+        disk_offering.tags,
+        disk_offering.removed,
+        disk_offering.use_local_storage,
+        disk_offering.system_use,
+        service_offering.cpu,
+        service_offering.speed,
+        service_offering.ram_size,
+        service_offering.nw_rate,
+        service_offering.mc_rate,
+        service_offering.ha_enabled,
+        service_offering.limit_cpu_use,
+        service_offering.host_tag,
+        service_offering.default_use,
+        service_offering.vm_type,
+        service_offering.sort_key,
+        domain.id domain_id,
+        domain.uuid domain_uuid,
+        domain.name domain_name,
+        domain.path domain_path
+    from
+        `cloud`.`service_offering`
+            inner join
+        `cloud`.`disk_offering` ON service_offering.id = disk_offering.id
+            left join
+        `cloud`.`domain` ON disk_offering.domain_id = domain.id;
+        
 INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'direct.agent.pool.size', '500', 'Default size for DirectAgentPool');