@@ -237,3 +237,210 @@ CREATE TABLE `cloud`.`external_opendaylight_controllers` (
237237 CONSTRAINT ` fk_external_opendaylight_devices__host_id` FOREIGN KEY (` host_id` ) REFERENCES ` host` (` id` ) ON DELETE CASCADE ,
238238 CONSTRAINT ` fk_external_opendaylight_devices__physical_network_id` FOREIGN KEY (` physical_network_id` ) REFERENCES ` physical_network` (` id` ) ON DELETE CASCADE
239239) ENGINE= InnoDB DEFAULT CHARSET= utf8;
240+
241+ DROP VIEW IF EXISTS ` cloud` .` user_vm_view` ;
242+ CREATE VIEW `cloud `.` user_vm_view` AS
243+ select
244+ vm_instance .id id,
245+ vm_instance .name name,
246+ user_vm .display_name display_name,
247+ user_vm .user_data user_data,
248+ account .id account_id,
249+ account .uuid account_uuid,
250+ account .account_name account_name,
251+ account .type account_type,
252+ domain .id domain_id,
253+ domain .uuid domain_uuid,
254+ domain .name domain_name,
255+ domain .path domain_path,
256+ projects .id project_id,
257+ projects .uuid project_uuid,
258+ projects .name project_name,
259+ instance_group .id instance_group_id,
260+ instance_group .uuid instance_group_uuid,
261+ instance_group .name instance_group_name,
262+ vm_instance .uuid uuid,
263+ vm_instance .last_host_id last_host_id,
264+ vm_instance .vm_type type,
265+ vm_instance .vnc_password vnc_password,
266+ vm_instance .limit_cpu_use limit_cpu_use,
267+ vm_instance .created created,
268+ vm_instance .state state,
269+ vm_instance .removed removed,
270+ vm_instance .ha_enabled ha_enabled,
271+ vm_instance .hypervisor_type hypervisor_type,
272+ vm_instance .instance_name instance_name,
273+ vm_instance .guest_os_id guest_os_id,
274+ vm_instance .display_vm display_vm,
275+ guest_os .uuid guest_os_uuid,
276+ vm_instance .pod_id pod_id,
277+ host_pod_ref .uuid pod_uuid,
278+ vm_instance .private_ip_address private_ip_address,
279+ vm_instance .private_mac_address private_mac_address,
280+ vm_instance .vm_type vm_type,
281+ data_center .id data_center_id,
282+ data_center .uuid data_center_uuid,
283+ data_center .name data_center_name,
284+ data_center .is_security_group_enabled security_group_enabled,
285+ data_center .networktype data_center_type,
286+ host .id host_id,
287+ host .uuid host_uuid,
288+ host .name host_name,
289+ vm_template .id template_id,
290+ vm_template .uuid template_uuid,
291+ vm_template .name template_name,
292+ vm_template .display_text template_display_text,
293+ vm_template .enable_password password_enabled,
294+ iso .id iso_id,
295+ iso .uuid iso_uuid,
296+ iso .name iso_name,
297+ iso .display_text iso_display_text,
298+ service_offering .id service_offering_id,
299+ svc_disk_offering .uuid service_offering_uuid,
300+ disk_offering .uuid disk_offering_uuid,
301+ disk_offering .id disk_offering_id,
302+ Case
303+ When (` cloud` .` service_offering` .` cpu` is null ) then (` custom_cpu` .` value` )
304+ Else ( ` cloud` .` service_offering` .` cpu` )
305+ End as ` cpu` ,
306+ Case
307+ When (` cloud` .` service_offering` .` speed` is null ) then (` custom_speed` .` value` )
308+ Else ( ` cloud` .` service_offering` .` speed` )
309+ End as ` speed` ,
310+ Case
311+ When (` cloud` .` service_offering` .` ram_size` is null ) then (` custom_ram_size` .` value` )
312+ Else ( ` cloud` .` service_offering` .` ram_size` )
313+ END as ` ram_size` ,
314+ svc_disk_offering .name service_offering_name,
315+ disk_offering .name disk_offering_name,
316+ storage_pool .id pool_id,
317+ storage_pool .uuid pool_uuid,
318+ storage_pool .pool_type pool_type,
319+ volumes .id volume_id,
320+ volumes .uuid volume_uuid,
321+ volumes .device_id volume_device_id,
322+ volumes .volume_type volume_type,
323+ security_group .id security_group_id,
324+ security_group .uuid security_group_uuid,
325+ security_group .name security_group_name,
326+ security_group .description security_group_description,
327+ nics .id nic_id,
328+ nics .uuid nic_uuid,
329+ nics .network_id network_id,
330+ nics .ip4_address ip_address,
331+ nics .ip6_address ip6_address,
332+ nics .ip6_gateway ip6_gateway,
333+ nics .ip6_cidr ip6_cidr,
334+ nics .default_nic is_default_nic,
335+ nics .gateway gateway,
336+ nics .netmask netmask,
337+ nics .mac_address mac_address,
338+ nics .broadcast_uri broadcast_uri,
339+ nics .isolation_uri isolation_uri,
340+ vpc .id vpc_id,
341+ vpc .uuid vpc_uuid,
342+ networks .uuid network_uuid,
343+ networks .name network_name,
344+ networks .traffic_type traffic_type,
345+ networks .guest_type guest_type,
346+ user_ip_address .id public_ip_id,
347+ user_ip_address .uuid public_ip_uuid,
348+ user_ip_address .public_ip_address public_ip_address,
349+ ssh_keypairs .keypair_name keypair_name,
350+ resource_tags .id tag_id,
351+ resource_tags .uuid tag_uuid,
352+ resource_tags .key tag_key,
353+ resource_tags .value tag_value,
354+ resource_tags .domain_id tag_domain_id,
355+ resource_tags .account_id tag_account_id,
356+ resource_tags .resource_id tag_resource_id,
357+ resource_tags .resource_uuid tag_resource_uuid,
358+ resource_tags .resource_type tag_resource_type,
359+ resource_tags .customer tag_customer,
360+ async_job .id job_id,
361+ async_job .uuid job_uuid,
362+ async_job .job_status job_status,
363+ async_job .account_id job_account_id,
364+ affinity_group .id affinity_group_id,
365+ affinity_group .uuid affinity_group_uuid,
366+ affinity_group .name affinity_group_name,
367+ affinity_group .description affinity_group_description,
368+ vm_instance .dynamically_scalable dynamically_scalable,
369+ all_details .name detail_name,
370+ all_details .value detail_value
371+
372+ from
373+ ` cloud` .` user_vm`
374+ inner join
375+ ` cloud` .` vm_instance` ON vm_instance .id = user_vm .id
376+ and vm_instance .removed is NULL
377+ inner join
378+ ` cloud` .` account` ON vm_instance .account_id = account .id
379+ inner join
380+ ` cloud` .` domain` ON vm_instance .domain_id = domain .id
381+ left join
382+ ` cloud` .` guest_os` ON vm_instance .guest_os_id = guest_os .id
383+ left join
384+ ` cloud` .` host_pod_ref` ON vm_instance .pod_id = host_pod_ref .id
385+ left join
386+ ` cloud` .` projects` ON projects .project_account_id = account .id
387+ left join
388+ ` cloud` .` instance_group_vm_map` ON vm_instance .id = instance_group_vm_map .instance_id
389+ left join
390+ ` cloud` .` instance_group` ON instance_group_vm_map .group_id = instance_group .id
391+ left join
392+ ` cloud` .` data_center` ON vm_instance .data_center_id = data_center .id
393+ left join
394+ ` cloud` .` host` ON vm_instance .host_id = host .id
395+ left join
396+ ` cloud` .` vm_template` ON vm_instance .vm_template_id = vm_template .id
397+ left join
398+ ` cloud` .` vm_template` iso ON iso .id = user_vm .iso_id
399+ left join
400+ ` cloud` .` service_offering` ON vm_instance .service_offering_id = service_offering .id
401+ left join
402+ ` cloud` .` disk_offering` svc_disk_offering ON vm_instance .service_offering_id = svc_disk_offering .id
403+ left join
404+ ` cloud` .` disk_offering` ON vm_instance .disk_offering_id = disk_offering .id
405+ left join
406+ ` cloud` .` volumes` ON vm_instance .id = volumes .instance_id
407+ left join
408+ ` cloud` .` storage_pool` ON volumes .pool_id = storage_pool .id
409+ left join
410+ ` cloud` .` security_group_vm_map` ON vm_instance .id = security_group_vm_map .instance_id
411+ left join
412+ ` cloud` .` security_group` ON security_group_vm_map .security_group_id = security_group .id
413+ left join
414+ ` cloud` .` nics` ON vm_instance .id = nics .instance_id and nics .removed is null
415+ left join
416+ ` cloud` .` networks` ON nics .network_id = networks .id
417+ left join
418+ ` cloud` .` vpc` ON networks .vpc_id = vpc .id and vpc .removed is null
419+ left join
420+ ` cloud` .` user_ip_address` ON user_ip_address .vm_id = vm_instance .id
421+ left join
422+ ` cloud` .` user_vm_details` as ssh_details ON ssh_details .vm_id = vm_instance .id
423+ and ssh_details .name = ' SSH.PublicKey'
424+ left join
425+ ` cloud` .` ssh_keypairs` ON ssh_keypairs .public_key = ssh_details .value
426+ left join
427+ ` cloud` .` resource_tags` ON resource_tags .resource_id = vm_instance .id
428+ and resource_tags .resource_type = ' UserVm'
429+ left join
430+ ` cloud` .` async_job` ON async_job .instance_id = vm_instance .id
431+ and async_job .instance_type = ' VirtualMachine'
432+ and async_job .job_status = 0
433+ left join
434+ ` cloud` .` affinity_group_vm_map` ON vm_instance .id = affinity_group_vm_map .instance_id
435+ left join
436+ ` cloud` .` affinity_group` ON affinity_group_vm_map .affinity_group_id = affinity_group .id
437+ left join
438+ ` cloud` .` user_vm_details` as all_details ON all_details .vm_id = vm_instance .id
439+ left join
440+ ` cloud` .` user_vm_details` ` custom_cpu` ON (((` custom_cpu` .` vm_id` = ` cloud` .` vm_instance` .` id` ) and (` custom_cpu` .` name` = ' CpuNumber' )))
441+ left join
442+ ` cloud` .` user_vm_details` ` custom_speed` ON (((` custom_speed` .` vm_id` = ` cloud` .` vm_instance` .` id` ) and (` custom_speed` .` name` = ' CpuSpeed' )))
443+ left join
444+ ` cloud` .` user_vm_details` ` custom_ram_size` ON (((` custom_ram_size` .` vm_id` = ` cloud` .` vm_instance` .` id` ) and (` custom_ram_size` .` name` = ' memory' )));
445+
446+
0 commit comments