blob: 14fd87536aa17341dae6d2726b58626142e8d2f9 [file] [log] [blame]
-- 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`.`domain_view`;
DROP VIEW IF EXISTS `cloud`.`domain_view`;
CREATE VIEW `cloud`.`domain_view` AS
select
`domain`.`id` AS `id`,
`domain`.`parent` AS `parent`,
`domain`.`name` AS `name`,
`domain`.`uuid` AS `uuid`,
`domain`.`owner` AS `owner`,
`domain`.`path` AS `path`,
`domain`.`level` AS `level`,
`domain`.`child_count` AS `child_count`,
`domain`.`next_child_seq` AS `next_child_seq`,
`domain`.`created` AS `created`,
`domain`.`removed` AS `removed`,
`domain`.`state` AS `state`,
`domain`.`network_domain` AS `network_domain`,
`domain`.`type` AS `type`,
`vmlimit`.`max` AS `vmLimit`,
`vmcount`.`count` AS `vmTotal`,
`iplimit`.`max` AS `ipLimit`,
`ipcount`.`count` AS `ipTotal`,
`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`,
`gpulimit`.`max` AS `gpuLimit`,
`gpucount`.`count` AS `gpuTotal`,
`primary_storage_limit`.`max` AS `primaryStorageLimit`,
`primary_storage_count`.`count` AS `primaryStorageTotal`,
`secondary_storage_limit`.`max` AS `secondaryStorageLimit`,
`secondary_storage_count`.`count` AS `secondaryStorageTotal`,
`backup_limit`.`max` AS `backupLimit`,
`backup_count`.`count` AS `backupTotal`,
`backup_storage_limit`.`max` AS `backupStorageLimit`,
`backup_storage_count`.`count` AS `backupStorageTotal`,
`bucket_limit`.`max` AS `bucketLimit`,
`bucket_count`.`count` AS `bucketTotal`,
`object_storage_limit`.`max` AS `objectStorageLimit`,
`object_storage_count`.`count` AS `objectStorageTotal`
from
`cloud`.`domain`
left join
`cloud`.`resource_limit` vmlimit ON domain.id = vmlimit.domain_id
and vmlimit.type = 'user_vm' and vmlimit.tag IS NULL
left join
`cloud`.`resource_count` vmcount ON domain.id = vmcount.domain_id
and vmcount.type = 'user_vm' and vmcount.tag IS NULL
left join
`cloud`.`resource_limit` iplimit ON domain.id = iplimit.domain_id
and iplimit.type = 'public_ip'
left join
`cloud`.`resource_count` ipcount ON domain.id = ipcount.domain_id
and ipcount.type = 'public_ip'
left join
`cloud`.`resource_limit` volumelimit ON domain.id = volumelimit.domain_id
and volumelimit.type = 'volume' and volumelimit.tag IS NULL
left join
`cloud`.`resource_count` volumecount ON domain.id = volumecount.domain_id
and volumecount.type = 'volume' and volumecount.tag IS NULL
left join
`cloud`.`resource_limit` snapshotlimit ON domain.id = snapshotlimit.domain_id
and snapshotlimit.type = 'snapshot'
left join
`cloud`.`resource_count` snapshotcount ON domain.id = snapshotcount.domain_id
and snapshotcount.type = 'snapshot'
left join
`cloud`.`resource_limit` templatelimit ON domain.id = templatelimit.domain_id
and templatelimit.type = 'template'
left join
`cloud`.`resource_count` templatecount ON domain.id = templatecount.domain_id
and templatecount.type = 'template'
left join
`cloud`.`resource_limit` vpclimit ON domain.id = vpclimit.domain_id
and vpclimit.type = 'vpc'
left join
`cloud`.`resource_count` vpccount ON domain.id = vpccount.domain_id
and vpccount.type = 'vpc'
left join
`cloud`.`resource_limit` projectlimit ON domain.id = projectlimit.domain_id
and projectlimit.type = 'project'
left join
`cloud`.`resource_count` projectcount ON domain.id = projectcount.domain_id
and projectcount.type = 'project'
left join
`cloud`.`resource_limit` networklimit ON domain.id = networklimit.domain_id
and networklimit.type = 'network'
left join
`cloud`.`resource_count` networkcount ON domain.id = networkcount.domain_id
and networkcount.type = 'network'
left join
`cloud`.`resource_limit` cpulimit ON domain.id = cpulimit.domain_id
and cpulimit.type = 'cpu' and cpulimit.tag IS NULL
left join
`cloud`.`resource_count` cpucount ON domain.id = cpucount.domain_id
and cpucount.type = 'cpu' and cpucount.tag IS NULL
left join
`cloud`.`resource_limit` memorylimit ON domain.id = memorylimit.domain_id
and memorylimit.type = 'memory' and memorylimit.tag IS NULL
left join
`cloud`.`resource_count` memorycount ON domain.id = memorycount.domain_id
and memorycount.type = 'memory' and memorycount.tag IS NULL
left join
`cloud`.`resource_limit` gpulimit ON domain.id = gpulimit.domain_id
and gpulimit.type = 'gpu' and gpulimit.tag IS NULL
left join
`cloud`.`resource_count` gpucount ON domain.id = gpucount.domain_id
and gpucount.type = 'gpu' and gpucount.tag IS NULL
left join
`cloud`.`resource_limit` primary_storage_limit ON domain.id = primary_storage_limit.domain_id
and primary_storage_limit.type = 'primary_storage' and primary_storage_limit.tag IS NULL
left join
`cloud`.`resource_count` primary_storage_count ON domain.id = primary_storage_count.domain_id
and primary_storage_count.type = 'primary_storage' and primary_storage_count.tag IS NULL
left join
`cloud`.`resource_limit` secondary_storage_limit ON domain.id = secondary_storage_limit.domain_id
and secondary_storage_limit.type = 'secondary_storage'
left join
`cloud`.`resource_count` secondary_storage_count ON domain.id = secondary_storage_count.domain_id
and secondary_storage_count.type = 'secondary_storage'
left join
`cloud`.`resource_limit` backup_limit ON domain.id = backup_limit.domain_id
and backup_limit.type = 'backup'
left join
`cloud`.`resource_count` backup_count ON domain.id = backup_count.domain_id
and backup_count.type = 'backup'
left join
`cloud`.`resource_limit` backup_storage_limit ON domain.id = backup_storage_limit.domain_id
and backup_storage_limit.type = 'backup_storage'
left join
`cloud`.`resource_count` backup_storage_count ON domain.id = backup_storage_count.domain_id
and backup_storage_count.type = 'backup_storage'
left join
`cloud`.`resource_limit` bucket_limit ON domain.id = bucket_limit.domain_id
and bucket_limit.type = 'bucket'
left join
`cloud`.`resource_count` bucket_count ON domain.id = bucket_count.domain_id
and bucket_count.type = 'bucket'
left join
`cloud`.`resource_limit` object_storage_limit ON domain.id = object_storage_limit.domain_id
and object_storage_limit.type = 'object_storage'
left join
`cloud`.`resource_count` object_storage_count ON domain.id = object_storage_count.domain_id
and object_storage_count.type = 'object_storage';