diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.account_netstats_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_netstats_view.sql new file mode 100644 index 00000000000..11193c465fd --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_netstats_view.sql @@ -0,0 +1,31 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.account_netstats_view source + + +DROP VIEW IF EXISTS `cloud`.`account_netstats_view`; + +CREATE VIEW `cloud`.`account_netstats_view` AS +select + `user_statistics`.`account_id` AS `account_id`, + (sum(`user_statistics`.`net_bytes_received`) + sum(`user_statistics`.`current_bytes_received`)) AS `bytesReceived`, + (sum(`user_statistics`.`net_bytes_sent`) + sum(`user_statistics`.`current_bytes_sent`)) AS `bytesSent` +from + `user_statistics` +group by + `user_statistics`.`account_id`; diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql new file mode 100644 index 00000000000..27d70b4171c --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_view.sql @@ -0,0 +1,166 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.account_view source + + +DROP VIEW IF EXISTS `cloud`.`account_view`; + +CREATE VIEW `cloud`.`account_view` AS +select + `account`.`id` AS `id`, + `account`.`uuid` AS `uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `type`, + `account`.`role_id` AS `role_id`, + `account`.`state` AS `state`, + `account`.`created` AS `created`, + `account`.`removed` AS `removed`, + `account`.`cleanup_needed` AS `cleanup_needed`, + `account`.`network_domain` AS `network_domain`, + `account`.`default` AS `default`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `data_center`.`id` AS `data_center_id`, + `data_center`.`uuid` AS `data_center_uuid`, + `data_center`.`name` AS `data_center_name`, + `account_netstats_view`.`bytesReceived` AS `bytesReceived`, + `account_netstats_view`.`bytesSent` AS `bytesSent`, + `vmlimit`.`max` AS `vmLimit`, + `vmcount`.`count` AS `vmTotal`, + `runningvm`.`vmcount` AS `runningVms`, + `stoppedvm`.`vmcount` AS `stoppedVms`, + `iplimit`.`max` AS `ipLimit`, + `ipcount`.`count` AS `ipTotal`, + `free_ip_view`.`free_ip` AS `ipFree`, + `volumelimit`.`max` AS `volumeLimit`, + `volumecount`.`count` AS `volumeTotal`, + `snapshotlimit`.`max` AS `snapshotLimit`, + `snapshotcount`.`count` AS `snapshotTotal`, + `templatelimit`.`max` AS `templateLimit`, + `templatecount`.`count` AS `templateTotal`, + `vpclimit`.`max` AS `vpcLimit`, + `vpccount`.`count` AS `vpcTotal`, + `projectlimit`.`max` AS `projectLimit`, + `projectcount`.`count` AS `projectTotal`, + `networklimit`.`max` AS `networkLimit`, + `networkcount`.`count` AS `networkTotal`, + `cpulimit`.`max` AS `cpuLimit`, + `cpucount`.`count` AS `cpuTotal`, + `memorylimit`.`max` AS `memoryLimit`, + `memorycount`.`count` AS `memoryTotal`, + `primary_storage_limit`.`max` AS `primaryStorageLimit`, + `primary_storage_count`.`count` AS `primaryStorageTotal`, + `secondary_storage_limit`.`max` AS `secondaryStorageLimit`, + `secondary_storage_count`.`count` AS `secondaryStorageTotal`, + `async_job`.`id` AS `job_id`, + `async_job`.`uuid` AS `job_uuid`, + `async_job`.`job_status` AS `job_status`, + `async_job`.`account_id` AS `job_account_id` +from + (`free_ip_view` +join ((((((((((((((((((((((((((((((`account` +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 `resource_limit` `cpulimit` on + (((`account`.`id` = `cpulimit`.`account_id`) + and (`cpulimit`.`type` = 'cpu')))) +left join `resource_count` `cpucount` on + (((`account`.`id` = `cpucount`.`account_id`) + and (`cpucount`.`type` = 'cpu')))) +left join `resource_limit` `memorylimit` on + (((`account`.`id` = `memorylimit`.`account_id`) + and (`memorylimit`.`type` = 'memory')))) +left join `resource_count` `memorycount` on + (((`account`.`id` = `memorycount`.`account_id`) + and (`memorycount`.`type` = 'memory')))) +left join `resource_limit` `primary_storage_limit` on + (((`account`.`id` = `primary_storage_limit`.`account_id`) + and (`primary_storage_limit`.`type` = 'primary_storage')))) +left join `resource_count` `primary_storage_count` on + (((`account`.`id` = `primary_storage_count`.`account_id`) + and (`primary_storage_count`.`type` = 'primary_storage')))) +left join `resource_limit` `secondary_storage_limit` on + (((`account`.`id` = `secondary_storage_limit`.`account_id`) + and (`secondary_storage_limit`.`type` = 'secondary_storage')))) +left join `resource_count` `secondary_storage_count` on + (((`account`.`id` = `secondary_storage_count`.`account_id`) + and (`secondary_storage_count`.`type` = 'secondary_storage')))) +left join `async_job` on + (((`async_job`.`instance_id` = `account`.`id`) + and (`async_job`.`instance_type` = 'Account') + and (`async_job`.`job_status` = 0))))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.account_vmstats_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_vmstats_view.sql new file mode 100644 index 00000000000..df6a216b0f8 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.account_vmstats_view.sql @@ -0,0 +1,35 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.account_vmstats_view source + + +DROP VIEW IF EXISTS `cloud`.`account_vmstats_view`; + +CREATE VIEW `cloud`.`account_vmstats_view` AS +select + `vm_instance`.`account_id` AS `account_id`, + `vm_instance`.`state` AS `state`, + count(0) AS `vmcount` +from + `vm_instance` +where + ((`vm_instance`.`vm_type` = 'User') + and (`vm_instance`.`removed` is null)) +group by + `vm_instance`.`account_id`, + `vm_instance`.`state`; diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.affinity_group_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.affinity_group_view.sql new file mode 100644 index 00000000000..90a398e1ec5 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.affinity_group_view.sql @@ -0,0 +1,60 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.affinity_group_view source + + +DROP VIEW IF EXISTS `cloud`.`affinity_group_view`; + +CREATE VIEW `cloud`.`affinity_group_view` AS +select + `affinity_group`.`id` AS `id`, + `affinity_group`.`name` AS `name`, + `affinity_group`.`type` AS `type`, + `affinity_group`.`description` AS `description`, + `affinity_group`.`uuid` AS `uuid`, + `affinity_group`.`acl_type` AS `acl_type`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `vm_instance`.`id` AS `vm_id`, + `vm_instance`.`uuid` AS `vm_uuid`, + `vm_instance`.`name` AS `vm_name`, + `vm_instance`.`state` AS `vm_state`, + `user_vm`.`display_name` AS `vm_display_name` +from + ((((((`affinity_group` +join `account` on + ((`affinity_group`.`account_id` = `account`.`id`))) +join `domain` on + ((`affinity_group`.`domain_id` = `domain`.`id`))) +left join `projects` on + ((`projects`.`project_account_id` = `account`.`id`))) +left join `affinity_group_vm_map` on + ((`affinity_group`.`id` = `affinity_group_vm_map`.`affinity_group_id`))) +left join `vm_instance` on + ((`vm_instance`.`id` = `affinity_group_vm_map`.`instance_id`))) +left join `user_vm` on + ((`user_vm`.`id` = `vm_instance`.`id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.domain_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.domain_view.sql new file mode 100644 index 00000000000..90a398e1ec5 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.domain_view.sql @@ -0,0 +1,60 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.affinity_group_view source + + +DROP VIEW IF EXISTS `cloud`.`affinity_group_view`; + +CREATE VIEW `cloud`.`affinity_group_view` AS +select + `affinity_group`.`id` AS `id`, + `affinity_group`.`name` AS `name`, + `affinity_group`.`type` AS `type`, + `affinity_group`.`description` AS `description`, + `affinity_group`.`uuid` AS `uuid`, + `affinity_group`.`acl_type` AS `acl_type`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `vm_instance`.`id` AS `vm_id`, + `vm_instance`.`uuid` AS `vm_uuid`, + `vm_instance`.`name` AS `vm_name`, + `vm_instance`.`state` AS `vm_state`, + `user_vm`.`display_name` AS `vm_display_name` +from + ((((((`affinity_group` +join `account` on + ((`affinity_group`.`account_id` = `account`.`id`))) +join `domain` on + ((`affinity_group`.`domain_id` = `domain`.`id`))) +left join `projects` on + ((`projects`.`project_account_id` = `account`.`id`))) +left join `affinity_group_vm_map` on + ((`affinity_group`.`id` = `affinity_group_vm_map`.`affinity_group_id`))) +left join `vm_instance` on + ((`vm_instance`.`id` = `affinity_group_vm_map`.`instance_id`))) +left join `user_vm` on + ((`user_vm`.`id` = `vm_instance`.`id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.event_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.event_view.sql new file mode 100644 index 00000000000..0a15ae4c0c9 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.event_view.sql @@ -0,0 +1,63 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.event_view source + + +DROP VIEW IF EXISTS `cloud`.`event_view`; + +CREATE VIEW `cloud`.`event_view` AS +select + `event`.`id` AS `id`, + `event`.`uuid` AS `uuid`, + `event`.`type` AS `type`, + `event`.`state` AS `state`, + `event`.`description` AS `description`, + `event`.`resource_id` AS `resource_id`, + `event`.`resource_type` AS `resource_type`, + `event`.`created` AS `created`, + `event`.`level` AS `level`, + `event`.`parameters` AS `parameters`, + `event`.`start_id` AS `start_id`, + `eve`.`uuid` AS `start_uuid`, + `event`.`user_id` AS `user_id`, + `event`.`archived` AS `archived`, + `event`.`display` AS `display`, + `user`.`username` AS `user_name`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name` +from + (((((`event` +join `account` on + ((`event`.`account_id` = `account`.`id`))) +join `domain` on + ((`event`.`domain_id` = `domain`.`id`))) +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`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.free_ip_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.free_ip_view.sql new file mode 100644 index 00000000000..29c22f33215 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.free_ip_view.sql @@ -0,0 +1,32 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.free_ip_view source + + +DROP VIEW IF EXISTS `cloud`.`free_ip_view`; + +CREATE VIEW `cloud`.`free_ip_view` AS +select + count(`user_ip_address`.`id`) AS `free_ip` +from + (`user_ip_address` +join `vlan` on + (((`vlan`.`id` = `user_ip_address`.`vlan_db_id`) + and (`vlan`.`vlan_type` = 'VirtualNetwork')))) +where + (`user_ip_address`.`state` = 'Free'); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.image_store_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.image_store_view.sql new file mode 100644 index 00000000000..88d68302d4c --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.image_store_view.sql @@ -0,0 +1,45 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.image_store_view source + + +DROP VIEW IF EXISTS `cloud`.`image_store_view`; + +CREATE VIEW `cloud`.`image_store_view` AS +select + `image_store`.`id` AS `id`, + `image_store`.`uuid` AS `uuid`, + `image_store`.`name` AS `name`, + `image_store`.`image_provider_name` AS `image_provider_name`, + `image_store`.`protocol` AS `protocol`, + `image_store`.`url` AS `url`, + `image_store`.`scope` AS `scope`, + `image_store`.`role` AS `role`, + `image_store`.`readonly` AS `readonly`, + `image_store`.`removed` AS `removed`, + `data_center`.`id` AS `data_center_id`, + `data_center`.`uuid` AS `data_center_uuid`, + `data_center`.`name` AS `data_center_name`, + `image_store_details`.`name` AS `detail_name`, + `image_store_details`.`value` AS `detail_value` +from + ((`image_store` +left join `data_center` on + ((`image_store`.`data_center_id` = `data_center`.`id`))) +left join `image_store_details` on + ((`image_store_details`.`store_id` = `image_store`.`id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.instance_group_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.instance_group_view.sql new file mode 100644 index 00000000000..8bdc8184718 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.instance_group_view.sql @@ -0,0 +1,48 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.instance_group_view source + + +DROP VIEW IF EXISTS `cloud`.`instance_group_view`; + +CREATE VIEW `cloud`.`instance_group_view` AS +select + `instance_group`.`id` AS `id`, + `instance_group`.`uuid` AS `uuid`, + `instance_group`.`name` AS `name`, + `instance_group`.`removed` AS `removed`, + `instance_group`.`created` AS `created`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name` +from + (((`instance_group` +join `account` on + ((`instance_group`.`account_id` = `account`.`id`))) +join `domain` on + ((`account`.`domain_id` = `domain`.`id`))) +left join `projects` on + ((`projects`.`project_account_id` = `instance_group`.`account_id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.last_annotation_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.last_annotation_view.sql new file mode 100644 index 00000000000..f317fbacc4d --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.last_annotation_view.sql @@ -0,0 +1,43 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.last_annotation_view source + + +DROP VIEW IF EXISTS `cloud`.`last_annotation_view`; + +CREATE VIEW `cloud`.`last_annotation_view` AS +select + `annotations`.`uuid` AS `uuid`, + `annotations`.`annotation` AS `annotation`, + `annotations`.`entity_uuid` AS `entity_uuid`, + `annotations`.`entity_type` AS `entity_type`, + `annotations`.`user_uuid` AS `user_uuid`, + `annotations`.`created` AS `created`, + `annotations`.`removed` AS `removed` +from + `annotations` +where + `annotations`.`created` in ( + select + max(`annotations`.`created`) + from + `annotations` + where + (`annotations`.`removed` is null) + group by + `annotations`.`entity_uuid`); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_view.sql new file mode 100644 index 00000000000..9b68f170e38 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.mshost_view.sql @@ -0,0 +1,46 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.mshost_view source + + +DROP VIEW IF EXISTS `cloud`.`mshost_view`; + +CREATE VIEW `cloud`.`mshost_view` AS +select + `mshost`.`id` AS `id`, + `mshost`.`msid` AS `msid`, + `mshost`.`runid` AS `runid`, + `mshost`.`name` AS `name`, + `mshost`.`uuid` AS `uuid`, + `mshost`.`state` AS `state`, + `mshost`.`version` AS `version`, + `mshost`.`service_ip` AS `service_ip`, + `mshost`.`service_port` AS `service_port`, + `mshost`.`last_update` AS `last_update`, + `mshost`.`removed` AS `removed`, + `mshost`.`alert_count` AS `alert_count`, + `mshost_status`.`last_jvm_start` AS `last_jvm_start`, + `mshost_status`.`last_jvm_stop` AS `last_jvm_stop`, + `mshost_status`.`last_system_boot` AS `last_system_boot`, + `mshost_status`.`os_distribution` AS `os_distribution`, + `mshost_status`.`java_name` AS `java_name`, + `mshost_status`.`java_version` AS `java_version` +from + (`mshost` +left join `mshost_status` on + ((`mshost`.`uuid` = `mshost_status`.`ms_id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.project_account_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_account_view.sql new file mode 100644 index 00000000000..c89618970cd --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_account_view.sql @@ -0,0 +1,54 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.project_account_view source + + +DROP VIEW IF EXISTS `cloud`.`project_account_view`; + +CREATE VIEW `cloud`.`project_account_view` AS +select + `project_account`.`id` AS `id`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `user`.`id` AS `user_id`, + `user`.`uuid` AS `user_uuid`, + `user`.`username` AS `user_name`, + `project_account`.`account_role` AS `account_role`, + `project_role`.`id` AS `project_role_id`, + `project_role`.`uuid` AS `project_role_uuid`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path` +from + (((((`project_account` +join `account` on + ((`project_account`.`account_id` = `account`.`id`))) +join `domain` on + ((`account`.`domain_id` = `domain`.`id`))) +join `projects` on + ((`projects`.`id` = `project_account`.`project_id`))) +left join `project_role` on + ((`project_account`.`project_role_id` = `project_role`.`id`))) +left join `user` on + ((`project_account`.`user_id` = `user`.`id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.project_invitation_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_invitation_view.sql new file mode 100644 index 00000000000..fae35b9373e --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_invitation_view.sql @@ -0,0 +1,52 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.project_invitation_view source + + +DROP VIEW IF EXISTS `cloud`.`project_invitation_view`; + +CREATE VIEW `cloud`.`project_invitation_view` AS +select + `project_invitations`.`id` AS `id`, + `project_invitations`.`uuid` AS `uuid`, + `project_invitations`.`email` AS `email`, + `project_invitations`.`created` AS `created`, + `project_invitations`.`state` AS `state`, + `project_invitations`.`project_role_id` AS `project_role_id`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `user`.`id` AS `user_id`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `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`))) +left join `user` on + ((`project_invitations`.`user_id` = `user`.`id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.project_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_view.sql new file mode 100644 index 00000000000..31461b1dd1e --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.project_view.sql @@ -0,0 +1,50 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.project_view source + + +DROP VIEW IF EXISTS `cloud`.`project_view`; + +CREATE VIEW `cloud`.`project_view` AS +select + `projects`.`id` AS `id`, + `projects`.`uuid` AS `uuid`, + `projects`.`name` AS `name`, + `projects`.`display_text` AS `display_text`, + `projects`.`state` AS `state`, + `projects`.`removed` AS `removed`, + `projects`.`created` AS `created`, + `projects`.`project_account_id` AS `project_account_id`, + `account`.`account_name` AS `owner`, + `pacct`.`account_id` AS `account_id`, + `pacct`.`user_id` AS `user_id`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path` +from + ((((`projects` +join `domain` on + ((`projects`.`domain_id` = `domain`.`id`))) +join `project_account` on + (((`projects`.`id` = `project_account`.`project_id`) + and (`project_account`.`account_role` = 'Admin')))) +join `account` on + ((`account`.`id` = `project_account`.`account_id`))) +left join `project_account` `pacct` on + ((`projects`.`id` = `pacct`.`project_id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.resource_tag_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.resource_tag_view.sql new file mode 100644 index 00000000000..3d77d49f870 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.resource_tag_view.sql @@ -0,0 +1,51 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.resource_tag_view source + + +DROP VIEW IF EXISTS `cloud`.`resource_tag_view`; + +CREATE VIEW `cloud`.`resource_tag_view` AS +select + `resource_tags`.`id` AS `id`, + `resource_tags`.`uuid` AS `uuid`, + `resource_tags`.`key` AS `key`, + `resource_tags`.`value` AS `value`, + `resource_tags`.`resource_id` AS `resource_id`, + `resource_tags`.`resource_uuid` AS `resource_uuid`, + `resource_tags`.`resource_type` AS `resource_type`, + `resource_tags`.`customer` AS `customer`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name` +from + (((`resource_tags` +join `account` on + ((`resource_tags`.`account_id` = `account`.`id`))) +join `domain` on + ((`resource_tags`.`domain_id` = `domain`.`id`))) +left join `projects` on + ((`projects`.`project_account_id` = `resource_tags`.`account_id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.security_group_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.security_group_view.sql new file mode 100644 index 00000000000..3cae860c1c3 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.security_group_view.sql @@ -0,0 +1,79 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.security_group_view source + + +DROP VIEW IF EXISTS `cloud`.`security_group_view`; + +CREATE VIEW `cloud`.`security_group_view` AS +select + `security_group`.`id` AS `id`, + `security_group`.`name` AS `name`, + `security_group`.`description` AS `description`, + `security_group`.`uuid` AS `uuid`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `security_group_rule`.`id` AS `rule_id`, + `security_group_rule`.`uuid` AS `rule_uuid`, + `security_group_rule`.`type` AS `rule_type`, + `security_group_rule`.`start_port` AS `rule_start_port`, + `security_group_rule`.`end_port` AS `rule_end_port`, + `security_group_rule`.`protocol` AS `rule_protocol`, + `security_group_rule`.`allowed_network_id` AS `rule_allowed_network_id`, + `security_group_rule`.`allowed_ip_cidr` AS `rule_allowed_ip_cidr`, + `security_group_rule`.`create_status` AS `rule_create_status`, + `resource_tags`.`id` AS `tag_id`, + `resource_tags`.`uuid` AS `tag_uuid`, + `resource_tags`.`key` AS `tag_key`, + `resource_tags`.`value` AS `tag_value`, + `resource_tags`.`domain_id` AS `tag_domain_id`, + `resource_tags`.`account_id` AS `tag_account_id`, + `resource_tags`.`resource_id` AS `tag_resource_id`, + `resource_tags`.`resource_uuid` AS `tag_resource_uuid`, + `resource_tags`.`resource_type` AS `tag_resource_type`, + `resource_tags`.`customer` AS `tag_customer`, + `async_job`.`id` AS `job_id`, + `async_job`.`uuid` AS `job_uuid`, + `async_job`.`job_status` AS `job_status`, + `async_job`.`account_id` AS `job_account_id` +from + ((((((`security_group` +left join `security_group_rule` on + ((`security_group`.`id` = `security_group_rule`.`security_group_id`))) +join `account` on + ((`security_group`.`account_id` = `account`.`id`))) +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)))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.volume_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.volume_view.sql new file mode 100644 index 00000000000..fd21fff1494 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.volume_view.sql @@ -0,0 +1,156 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- VIEW `cloud`.`volume_view`; + +DROP VIEW IF EXISTS `cloud`.`volume_view`; + +CREATE VIEW `cloud`.`volume_view` AS +SELECT + `volumes`.`id` AS `id`, + `volumes`.`uuid` AS `uuid`, + `volumes`.`name` AS `name`, + `volumes`.`device_id` AS `device_id`, + `volumes`.`volume_type` AS `volume_type`, + `volumes`.`provisioning_type` AS `provisioning_type`, + `volumes`.`size` AS `size`, + `volumes`.`min_iops` AS `min_iops`, + `volumes`.`max_iops` AS `max_iops`, + `volumes`.`created` AS `created`, + `volumes`.`state` AS `state`, + `volumes`.`attached` AS `attached`, + `volumes`.`removed` AS `removed`, + `volumes`.`display_volume` AS `display_volume`, + `volumes`.`format` AS `format`, + `volumes`.`path` AS `path`, + `volumes`.`chain_info` AS `chain_info`, + `volumes`.`external_uuid` AS `external_uuid`, + `account`.`id` AS `account_id`, + `account`.`uuid` AS `account_uuid`, + `account`.`account_name` AS `account_name`, + `account`.`type` AS `account_type`, + `domain`.`id` AS `domain_id`, + `domain`.`uuid` AS `domain_uuid`, + `domain`.`name` AS `domain_name`, + `domain`.`path` AS `domain_path`, + `projects`.`id` AS `project_id`, + `projects`.`uuid` AS `project_uuid`, + `projects`.`name` AS `project_name`, + `data_center`.`id` AS `data_center_id`, + `data_center`.`uuid` AS `data_center_uuid`, + `data_center`.`name` AS `data_center_name`, + `data_center`.`networktype` AS `data_center_type`, + `vm_instance`.`id` AS `vm_id`, + `vm_instance`.`uuid` AS `vm_uuid`, + `vm_instance`.`name` AS `vm_name`, + `vm_instance`.`state` AS `vm_state`, + `vm_instance`.`vm_type` AS `vm_type`, + `user_vm`.`display_name` AS `vm_display_name`, + `volume_store_ref`.`size` AS `volume_store_size`, + `volume_store_ref`.`download_pct` AS `download_pct`, + `volume_store_ref`.`download_state` AS `download_state`, + `volume_store_ref`.`error_str` AS `error_str`, + `volume_store_ref`.`created` AS `created_on_store`, + `disk_offering`.`id` AS `disk_offering_id`, + `disk_offering`.`uuid` AS `disk_offering_uuid`, + `disk_offering`.`name` AS `disk_offering_name`, + `disk_offering`.`display_text` AS `disk_offering_display_text`, + `disk_offering`.`use_local_storage` AS `use_local_storage`, + `service_offering`.`system_use` AS `system_use`, + `disk_offering`.`bytes_read_rate` AS `bytes_read_rate`, + `disk_offering`.`bytes_write_rate` AS `bytes_write_rate`, + `disk_offering`.`iops_read_rate` AS `iops_read_rate`, + `disk_offering`.`iops_write_rate` AS `iops_write_rate`, + `disk_offering`.`cache_mode` AS `cache_mode`, + `storage_pool`.`id` AS `pool_id`, + `storage_pool`.`uuid` AS `pool_uuid`, + `storage_pool`.`name` AS `pool_name`, + `cluster`.`id` AS `cluster_id`, + `cluster`.`name` AS `cluster_name`, + `cluster`.`uuid` AS `cluster_uuid`, + `cluster`.`hypervisor_type` AS `hypervisor_type`, + `vm_template`.`id` AS `template_id`, + `vm_template`.`uuid` AS `template_uuid`, + `vm_template`.`extractable` AS `extractable`, + `vm_template`.`type` AS `template_type`, + `vm_template`.`name` AS `template_name`, + `vm_template`.`display_text` AS `template_display_text`, + `iso`.`id` AS `iso_id`, + `iso`.`uuid` AS `iso_uuid`, + `iso`.`name` AS `iso_name`, + `iso`.`display_text` AS `iso_display_text`, + `resource_tags`.`id` AS `tag_id`, + `resource_tags`.`uuid` AS `tag_uuid`, + `resource_tags`.`key` AS `tag_key`, + `resource_tags`.`value` AS `tag_value`, + `resource_tags`.`domain_id` AS `tag_domain_id`, + `resource_tags`.`account_id` AS `tag_account_id`, + `resource_tags`.`resource_id` AS `tag_resource_id`, + `resource_tags`.`resource_uuid` AS `tag_resource_uuid`, + `resource_tags`.`resource_type` AS `tag_resource_type`, + `resource_tags`.`customer` AS `tag_customer`, + `async_job`.`id` AS `job_id`, + `async_job`.`uuid` AS `job_uuid`, + `async_job`.`job_status` AS `job_status`, + `async_job`.`account_id` AS `job_account_id`, + `host_pod_ref`.`id` AS `pod_id`, + `host_pod_ref`.`uuid` AS `pod_uuid`, + `host_pod_ref`.`name` AS `pod_name`, + `resource_tag_account`.`account_name` AS `tag_account_name`, + `resource_tag_domain`.`uuid` AS `tag_domain_uuid`, + `resource_tag_domain`.`name` AS `tag_domain_name` +FROM + ((((((((((((((((((`volumes` +JOIN `account`ON + ((`volumes`.`account_id` = `account`.`id`))) +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_store_ref`ON + ((`volumes`.`id` = `volume_store_ref`.`volume_id`))) +LEFT JOIN `service_offering`ON + ((`vm_instance`.`service_offering_id` = `service_offering`.`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 `host_pod_ref`ON + ((`storage_pool`.`pod_id` = `host_pod_ref`.`id`))) +LEFT JOIN `cluster`ON + ((`storage_pool`.`cluster_id` = `cluster`.`id`))) +LEFT JOIN `vm_template`ON + ((`volumes`.`template_id` = `vm_template`.`id`))) +LEFT JOIN `vm_template` `iso`ON + ((`iso`.`id` = `volumes`.`iso_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)))) +LEFT JOIN `account` `resource_tag_account`ON + ((`resource_tag_account`.`id` = `resource_tags`.`account_id`))) +LEFT JOIN `domain` `resource_tag_domain`ON + ((`resource_tag_domain`.`id` = `resource_tags`.`domain_id`))); diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.vpc_offering_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.vpc_offering_view.sql new file mode 100644 index 00000000000..cb762a57883 --- /dev/null +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.vpc_offering_view.sql @@ -0,0 +1,63 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- cloud.vpc_offering_view source + + +DROP VIEW IF EXISTS `cloud`.`vpc_offering_view`; + +CREATE VIEW `cloud`.`vpc_offering_view` AS +select + `vpc_offerings`.`id` AS `id`, + `vpc_offerings`.`uuid` AS `uuid`, + `vpc_offerings`.`name` AS `name`, + `vpc_offerings`.`unique_name` AS `unique_name`, + `vpc_offerings`.`display_text` AS `display_text`, + `vpc_offerings`.`state` AS `state`, + `vpc_offerings`.`default` AS `default`, + `vpc_offerings`.`created` AS `created`, + `vpc_offerings`.`removed` AS `removed`, + `vpc_offerings`.`service_offering_id` AS `service_offering_id`, + `vpc_offerings`.`supports_distributed_router` AS `supports_distributed_router`, + `vpc_offerings`.`supports_region_level_vpc` AS `supports_region_level_vpc`, + `vpc_offerings`.`redundant_router_service` AS `redundant_router_service`, + `vpc_offerings`.`sort_key` AS `sort_key`, + group_concat(distinct `domain`.`id` separator ',') AS `domain_id`, + group_concat(distinct `domain`.`uuid` separator ',') AS `domain_uuid`, + group_concat(distinct `domain`.`name` separator ',') AS `domain_name`, + group_concat(distinct `domain`.`path` separator ',') AS `domain_path`, + group_concat(distinct `zone`.`id` separator ',') AS `zone_id`, + group_concat(distinct `zone`.`uuid` separator ',') AS `zone_uuid`, + group_concat(distinct `zone`.`name` separator ',') AS `zone_name`, + `offering_details`.`value` AS `internet_protocol` +from + (((((`vpc_offerings` +left join `vpc_offering_details` `domain_details` on + (((`domain_details`.`offering_id` = `vpc_offerings`.`id`) + and (`domain_details`.`name` = 'domainid')))) +left join `domain` on + ((0 <> find_in_set(`domain`.`id`, `domain_details`.`value`)))) +left join `vpc_offering_details` `zone_details` on + (((`zone_details`.`offering_id` = `vpc_offerings`.`id`) + and (`zone_details`.`name` = 'zoneid')))) +left join `data_center` `zone` on + ((0 <> find_in_set(`zone`.`id`, `zone_details`.`value`)))) +left join `vpc_offering_details` `offering_details` on + (((`offering_details`.`offering_id` = `vpc_offerings`.`id`) + and (`offering_details`.`name` = 'internetprotocol')))) +group by + `vpc_offerings`.`id`;